Skip to content

Commit 058c98b

Browse files
authored
Introduce dependency on DataStructures (#21)
* Update PkgEval badges * Introduce dependency on DataStructures * Qualify call to ordtype * More depwarn fixes, bump Compat, add 0.5 to Travis * Use map instead of dot-broadcast * One more depwarn
1 parent daf9126 commit 058c98b

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

.travis.yml

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
language: julia
22
os:
3-
- osx
4-
- linux
3+
- osx
4+
- linux
55
julia:
6-
- 0.4
7-
- nightly
6+
- 0.4
7+
- 0.5
8+
- nightly
89
notifications:
9-
email: false
10-
script:
11-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
12-
- julia -e 'Pkg.clone(pwd()); Pkg.build("SortingAlgorithms"); Pkg.test("SortingAlgorithms"; coverage=true)'
13-
- julia -e 'cd(Pkg.dir("SortingAlgorithms")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
14-
10+
email: false
11+
#script:
12+
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
13+
# - julia -e 'Pkg.clone(pwd()); Pkg.build("SortingAlgorithms"); Pkg.test("SortingAlgorithms"; coverage=true)'
14+
after_success:
15+
- julia -e 'cd(Pkg.dir("SortingAlgorithms")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Sorting Algorithms
22

3-
[![SortingAlgorithms](http://pkg.julialang.org/badges/SortingAlgorithms_0.3.svg)](http://pkg.julialang.org/?pkg=SortingAlgorithms&ver=0.3)
4-
[![SortingAlgorithms](http://pkg.julialang.org/badges/SortingAlgorithms_0.4.svg)](http://pkg.julialang.org/?pkg=SortingAlgorithms&ver=0.4)
3+
[![SortingAlgorithms](http://pkg.julialang.org/badges/SortingAlgorithms_0.4.svg)](http://pkg.julialang.org/?pkg=SortingAlgorithms)
4+
[![SortingAlgorithms](http://pkg.julialang.org/badges/SortingAlgorithms_0.5.svg)](http://pkg.julialang.org/?pkg=SortingAlgorithms)
5+
[![SortingAlgorithms](http://pkg.julialang.org/badges/SortingAlgorithms_0.6.svg)](http://pkg.julialang.org/?pkg=SortingAlgorithms)
56
[![Build Status](https://travis-ci.org/JuliaLang/SortingAlgorithms.jl.svg?branch=master)](https://travis-ci.org/JuliaLang/SortingAlgorithms.jl)
67
[![Coverage Status](https://coveralls.io/repos/JuliaLang/SortingAlgorithms.jl/badge.svg)](https://coveralls.io/r/JuliaLang/SortingAlgorithms.jl)
78

REQUIRE

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
julia 0.4
2-
Compat 0.8.4
2+
Compat 0.9.4
3+
DataStructures 0.5.3

src/SortingAlgorithms.jl

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
__precompile__()
2+
13
module SortingAlgorithms
24

35
using Compat
6+
using DataStructures
47
import Compat.view
58
using Base.Sort
69
using Base.Order
710

811
import Base.Sort: sort!
9-
import Base.Collections: heapify!, percolate_down!
12+
import DataStructures: heapify!, percolate_down!
1013

1114
export HeapSort, TimSort, RadixSort
1215

@@ -45,10 +48,10 @@ end
4548
uint_mapping(::ForwardOrdering, x::Unsigned) = x
4649
for (signedty, unsignedty) in ((Int8, UInt8), (Int16, UInt16), (Int32, UInt32), (Int64, UInt64), (Int128, UInt128))
4750
# In Julia 0.4 we can just use unsigned() here
48-
@eval uint_mapping(::ForwardOrdering, x::$signedty) = reinterpret($unsignedty, x $ typemin(typeof(x)))
51+
@eval uint_mapping(::ForwardOrdering, x::$signedty) = reinterpret($unsignedty, xor(x, typemin(typeof(x))))
4952
end
50-
uint_mapping(::ForwardOrdering, x::Float32) = (y = reinterpret(Int32, x); reinterpret(UInt32, ifelse(y < 0, ~y, y $ typemin(Int32))))
51-
uint_mapping(::ForwardOrdering, x::Float64) = (y = reinterpret(Int64, x); reinterpret(UInt64, ifelse(y < 0, ~y, y $ typemin(Int64))))
53+
uint_mapping(::ForwardOrdering, x::Float32) = (y = reinterpret(Int32, x); reinterpret(UInt32, ifelse(y < 0, ~y, xor(y, typemin(Int32)))))
54+
uint_mapping(::ForwardOrdering, x::Float64) = (y = reinterpret(Int64, x); reinterpret(UInt64, ifelse(y < 0, ~y, xor(y, typemin(Int64)))))
5255

5356
uint_mapping{Fwd}(rev::ReverseOrdering{Fwd}, x) = ~uint_mapping(rev.fwd, x)
5457
uint_mapping{T<:Real}(::ReverseOrdering{ForwardOrdering}, x::T) = ~uint_mapping(Forward, x) # maybe unnecessary; needs benchmark
@@ -65,7 +68,7 @@ function sort!(vs::AbstractVector, lo::Int, hi::Int, ::RadixSortAlg, o::Ordering
6568
if lo >= hi; return vs; end
6669

6770
# Make sure we're sorting a bits type
68-
T = ordtype(o, vs)
71+
T = Base.Order.ordtype(o, vs)
6972
if !isbits(T)
7073
error("Radix sort only sorts bits types (got $T)")
7174
end
@@ -134,7 +137,7 @@ end
134137
#
135138
# Original author: @kmsquire
136139

137-
typealias Run UnitRange{Int}
140+
const Run = UnitRange{Int}
138141

139142
const MIN_GALLOP = 7
140143

test/runtests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ for n in [0:10..., 100, 101, 1000, 1001]
103103
# test float sorting with NaNs
104104
s = sort(v, alg=alg, order=ord)
105105
@test issorted(s, order=ord)
106-
@test reinterpret(UInt64,v[isnan(v)]) == reinterpret(UInt64,s[isnan(s)])
106+
@test reinterpret(UInt64, v[map(isnan, v)]) == reinterpret(UInt64, s[map(isnan, s)])
107107

108108
# test float permutation with NaNs
109109
p = sortperm(v, alg=alg, order=ord)

0 commit comments

Comments
 (0)