Skip to content

Commit 891173f

Browse files
authored
Merge pull request #28 from quinnj/jq/0.7
0.7 compat
2 parents 593642f + b6f6dd0 commit 891173f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Diff for: src/SortingAlgorithms.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function sort!(vs::AbstractVector, lo::Int, hi::Int, ::RadixSortAlg, o::Ordering
8282
for i = lo:hi
8383
v = uint_mapping(o, vs[i])
8484
for j = 1:iters
85-
idx = Int((v >> (j-1)*RADIX_SIZE) & RADIX_MASK) + 1
85+
idx = Int((v >> ((j-1)*RADIX_SIZE)) & RADIX_MASK) + 1
8686
@inbounds bin[idx,j] += 1
8787
end
8888
end
@@ -93,7 +93,7 @@ function sort!(vs::AbstractVector, lo::Int, hi::Int, ::RadixSortAlg, o::Ordering
9393
for j = 1:iters
9494
# Unroll first data iteration, check for degenerate case
9595
v = uint_mapping(o, vs[hi])
96-
idx = Int((v >> (j-1)*RADIX_SIZE) & RADIX_MASK) + 1
96+
idx = Int((v >> ((j-1)*RADIX_SIZE)) & RADIX_MASK) + 1
9797

9898
# are all values the same at this radix?
9999
if bin[idx,j] == len; continue; end
@@ -106,7 +106,7 @@ function sort!(vs::AbstractVector, lo::Int, hi::Int, ::RadixSortAlg, o::Ordering
106106
# Finish the loop...
107107
@inbounds for i in hi-1:-1:lo
108108
v = uint_mapping(o, vs[i])
109-
idx = Int((v >> (j-1)*RADIX_SIZE) & RADIX_MASK) + 1
109+
idx = Int((v >> ((j-1)*RADIX_SIZE)) & RADIX_MASK) + 1
110110
ci = cbin[idx]
111111
ts[ci] = vs[i]
112112
cbin[idx] -= 1

Diff for: test/runtests.jl

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
using Base.Test
21
using SortingAlgorithms
3-
using Compat
2+
using Compat, Compat.Test
43
using StatsBase
54

5+
if !isdefined(Base, :invpermute!)
6+
invpermute! = ipermute!
7+
end
8+
69
a = rand(1:10000, 1000)
710

811
for alg in [TimSort, HeapSort, RadixSort]
@@ -31,7 +34,7 @@ for alg in [TimSort, HeapSort, RadixSort]
3134
permute!(c, ix)
3235
@test c == b
3336

34-
ipermute!(c, ix)
37+
invpermute!(c, ix)
3538
@test c == a
3639

3740
if alg != RadixSort # RadixSort does not work with Lt orderings
@@ -70,7 +73,7 @@ for n in [0:10..., 100, 101, 1000, 1001]
7073
c = copy(v)
7174
permute!(c, pi)
7275
@test c == si
73-
ipermute!(c, pi)
76+
invpermute!(c, pi)
7477
@test c == v
7578

7679
# stable algorithms
@@ -80,7 +83,7 @@ for n in [0:10..., 100, 101, 1000, 1001]
8083
s = copy(v)
8184
permute!(s, p)
8285
@test s == si
83-
ipermute!(s, p)
86+
invpermute!(s, p)
8487
@test s == v
8588
end
8689

@@ -92,7 +95,7 @@ for n in [0:10..., 100, 101, 1000, 1001]
9295
s = copy(v)
9396
permute!(s, p)
9497
@test s == si
95-
ipermute!(s, p)
98+
invpermute!(s, p)
9699
@test s == v
97100
end
98101
end

0 commit comments

Comments
 (0)