Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecations incl sort! piracy, bump version to 2.0 #109

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "OrderedCollections"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.6.2"
version = "2.0.0"

[compat]
julia = "1.6"
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
OrderedCollections.jl
=====================

**Changes in v2.0:**

* removes deprecations present in v1.6.2 (for `sort!(::Dict)`, `similar(::Union{OrderedDict, OrderedSet})`, indexing, and `convert` from non-ordered types)
* removes `convert(::OrderedDict, ::AbstractDict)` method to reduce invalidations, instead falling back to Base's method, which uses the constructor. This results in copying keys and values.

This package implements OrderedDicts and OrderedSets, which are similar to containers in base Julia.
However, during iteration the Ordered* containers return items in the order in which they were added to the collection.
It also implements `LittleDict` which is a ordered dictionary, that is much faster than any other `AbstractDict` (ordered or not) for small collections.
Expand Down
3 changes: 0 additions & 3 deletions src/OrderedCollections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@ module OrderedCollections
include("ordered_set.jl")
include("dict_sorting.jl")

import Base: similar
@deprecate similar(d::OrderedDict) empty(d)
@deprecate similar(s::OrderedSet) empty(s)
end
3 changes: 0 additions & 3 deletions src/dict_sorting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ end

sort(d::Union{OrderedDict,OrderedSet}; args...) = sort!(copy(d); args...)

@deprecate sort(d::Dict; args...) sort!(OrderedDict(d); args...)

function sort(d::LittleDict; byvalue::Bool=false, args...)
if byvalue
p = sortperm(d.vals; args...)
Expand All @@ -43,4 +41,3 @@ function sort(d::LittleDict; byvalue::Bool=false, args...)
end
return LittleDict(d.keys[p], d.vals[p])
end

18 changes: 0 additions & 18 deletions src/ordered_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,6 @@ defined order (such as `OrderedDict` and `SortedDict`), and `false` otherwise.
isordered(::Type{T}) where {T<:AbstractDict} = false
isordered(::Type{T}) where {T<:OrderedDict} = true

# conversion between OrderedDict types
function convert(::Type{OrderedDict{K,V}}, d::AbstractDict) where {K,V}
d isa OrderedDict{K, V} && return d
if !isordered(typeof(d))
Base.depwarn("Conversion to OrderedDict is deprecated for unordered associative containers (in this case, $(typeof(d))). Use an ordered or sorted associative type, such as SortedDict and OrderedDict.", :convert)
end
h = OrderedDict{K,V}()
for (k,v) in d
ck = convert(K,k)
if !haskey(h,ck)
h[ck] = convert(V,v)
else
error("key collision during dictionary conversion")
end
end
return h
end

isslotempty(slot_value::Integer) = slot_value == 0
isslotfilled(slot_value::Integer) = slot_value > 0
isslotmissing(slot_value::Integer) = slot_value < 0
Expand Down
26 changes: 0 additions & 26 deletions src/ordered_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,3 @@ function hash(s::OrderedSet, h::UInt)
hash(s.dict.keys, h)
end


# Deprecated functionality, see
# https://github.com/JuliaCollections/DataStructures.jl/pull/180#issuecomment-400269803

function getindex(s::OrderedSet, i::Int)
Base.depwarn("indexing is deprecated for OrderedSet, please rewrite your code to use iteration", :getindex)
s.dict.ndel > 0 && rehash!(s.dict)
return s.dict.keys[i]
end

function lastindex(s::OrderedSet)
Base.depwarn("indexing is deprecated for OrderedSet, please rewrite your code to use iteration", :lastindex)
s.dict.ndel > 0 && rehash!(s.dict)
return lastindex(s.dict.keys)
end

function nextind(::OrderedSet, i::Int)
Base.depwarn("indexing is deprecated for OrderedSet, please rewrite your code to use iteration", :lastindex)
return i + 1 # Needed on 0.7 to mimic array indexing.
end

function keys(s::OrderedSet)
Base.depwarn("indexing is deprecated for OrderedSet, please rewrite your code to use iteration", :lastindex)
s.dict.ndel > 0 && rehash!(s.dict)
return 1:length(s)
end
Loading