Skip to content

Commit 593642f

Browse files
Nosfericankmsquire
authored andcommitted
Update syntax for structs / mutable structs. (#23)
* Update syntax for structs / mutable structs. immutable -> struct type -> mutable struct * Bump to 0.6 * Fix deprecations * Fix unused Fwd
1 parent 44fd7cc commit 593642f

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

Diff for: .travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ os:
33
- osx
44
- linux
55
julia:
6-
- 0.4
7-
- 0.5
6+
- 0.6
87
- nightly
98
notifications:
109
email: false

Diff for: REQUIRE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
julia 0.4
1+
julia 0.6
22
Compat 0.9.4
33
DataStructures 0.5.3

Diff for: src/SortingAlgorithms.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import DataStructures: heapify!, percolate_down!
1313

1414
export 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

2020
const HeapSort = HeapSortAlg()
2121
const TimSort = TimSortAlg()
@@ -53,8 +53,8 @@ end
5353
uint_mapping(::ForwardOrdering, x::Float32) = (y = reinterpret(Int32, x); reinterpret(UInt32, ifelse(y < 0, ~y, xor(y, typemin(Int32)))))
5454
uint_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

5959
uint_mapping(o::By, x ) = uint_mapping(Forward, o.by(x))
6060
uint_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

142142
const MIN_GALLOP = 7
143143

144-
type MergeState
144+
mutable struct MergeState
145145
runs::Vector{Run}
146146
min_gallop::Int
147147
end

0 commit comments

Comments
 (0)