Skip to content

Commit

Permalink
Remove uint_mapping. Fixes #8539
Browse files Browse the repository at this point in the history
Moved to SortingAlgorithms.jl in JuliaCollections/SortingAlgorithms.jl@ce5c2bd
  • Loading branch information
simonster committed Oct 1, 2014
1 parent a2566d7 commit 8d50815
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
27 changes: 1 addition & 26 deletions base/ordering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export # not exported by Base
By, Lt, Perm,
ReverseOrdering, ForwardOrdering, LexicographicOrdering,
DirectOrdering,
lt, uint_mapping, ord, ordtype
lt, ord, ordtype

abstract Ordering

Expand Down Expand Up @@ -57,31 +57,6 @@ function lt(p::Perm{LexicographicOrdering}, a::Int, b::Int)
c != 0 ? c < 0 : a < b
end

# Map a bits-type to an unsigned int, maintaining sort order
uint_mapping(::ForwardOrdering, x::Unsigned) = x
uint_mapping(::ForwardOrdering, x::Int8) = uint8 (x $ typemin(Int8))
uint_mapping(::ForwardOrdering, x::Int16) = uint16 (x $ typemin(Int16))
uint_mapping(::ForwardOrdering, x::Int32) = uint32 (x $ typemin(Int32))
uint_mapping(::ForwardOrdering, x::Int64) = uint64 (x $ typemin(Int64))
uint_mapping(::ForwardOrdering, x::Int128) = uint128(x $ typemin(Int128))
uint_mapping(::ForwardOrdering, x::Float32) = (y = reinterpret(Int32, x); uint32(y < 0 ? ~y : (y $ typemin(Int32))))
uint_mapping(::ForwardOrdering, x::Float64) = (y = reinterpret(Int64, x); uint64(y < 0 ? ~y : (y $ typemin(Int64))))

uint_mapping{Fwd}(::ReverseOrdering{Fwd}, x) = ~uint_mapping(Fwd, x)
#uint_mapping{T<:Real}(::ReverseOrdering{ForwardOrdering}, x::T) = ~uint_mapping(Forward, x) ## Manually inlined
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Unsigned) = ~x
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Int8) = ~uint8 (x $ typemin(Int8))
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Int16) = ~uint16 (x $ typemin(Int16))
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Int32) = ~uint32 (x $ typemin(Int32))
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Int64) = ~uint64 (x $ typemin(Int64))
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Int128) = ~uint128(x $ typemin(Int128))
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Float32) = (y = reinterpret(Int32, x); uint32(y < 0 ? y : ~(y $ typemin(Int32))))
uint_mapping(::ReverseOrdering{ForwardOrdering}, x::Float64) = (y = reinterpret(Int64, x); uint64(y < 0 ? y : ~(y $ typemin(Int64))))

uint_mapping(o::By, x ) = uint_mapping(Forward, o.by(x))
uint_mapping(o::Perm, i::Int) = uint_mapping(o.order, o.data[i])
uint_mapping(o::Lt, x ) = error("uint_mapping does not work with general Lt Orderings")

ordtype(o::ReverseOrdering, vs::AbstractArray) = ordtype(o.fwd, vs)
ordtype(o::Perm, vs::AbstractArray) = ordtype(o.order, o.data)
# TODO: here, we really want the return type of o.by, without calling it
Expand Down
2 changes: 1 addition & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ using ...Order

import Core.Intrinsics: unbox, slt_int
import ..Sort: sort!
import ...Order: lt, DirectOrdering, uint_mapping
import ...Order: lt, DirectOrdering

typealias Floats Union(Float32,Float64)

Expand Down

0 comments on commit 8d50815

Please sign in to comment.