@@ -13,9 +13,9 @@ import DataStructures: heapify!, percolate_down!
1313
1414export HeapSort, TimSort, RadixSort
1515
16- immutable HeapSortAlg <: Algorithm end
17- immutable TimSortAlg <: Algorithm end
18- immutable RadixSortAlg <: Algorithm end
16+ struct HeapSortAlg <: Algorithm end
17+ struct TimSortAlg <: Algorithm end
18+ struct RadixSortAlg <: Algorithm end
1919
2020const HeapSort = HeapSortAlg ()
2121const TimSort = TimSortAlg ()
5353uint_mapping (:: ForwardOrdering , x:: Float32 ) = (y = reinterpret (Int32, x); reinterpret (UInt32, ifelse (y < 0 , ~ y, xor (y, typemin (Int32)))))
5454uint_mapping (:: ForwardOrdering , x:: Float64 ) = (y = reinterpret (Int64, x); reinterpret (UInt64, ifelse (y < 0 , ~ y, xor (y, typemin (Int64)))))
5555
56- uint_mapping {Fwd} (rev:: ReverseOrdering{Fwd} , x) = ~ uint_mapping (rev. fwd, x)
57- uint_mapping {T<:Real} (:: ReverseOrdering{ForwardOrdering} , x:: T ) = ~ uint_mapping (Forward, x) # maybe unnecessary; needs benchmark
56+ uint_mapping (rev:: ReverseOrdering , x) = ~ uint_mapping (rev. fwd, x)
57+ uint_mapping (:: ReverseOrdering{ForwardOrdering} , x:: Real ) = ~ uint_mapping (Forward, x) # maybe unnecessary; needs benchmark
5858
5959uint_mapping (o:: By , x ) = uint_mapping (Forward, o. by (x))
6060uint_mapping (o:: Perm , i:: Int ) = uint_mapping (o. order, o. data[i])
@@ -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 = @compat ( 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 = @compat ( 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 = @compat ( 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
@@ -141,7 +141,7 @@ const Run = UnitRange{Int}
141141
142142const MIN_GALLOP = 7
143143
144- type MergeState
144+ mutable struct MergeState
145145 runs:: Vector{Run}
146146 min_gallop:: Int
147147end
0 commit comments