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

Mark as 0.18-DEV and remove deprecations #643

Merged
merged 3 commits into from
Aug 4, 2020
Merged
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 = "DataStructures"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.17.20"
version = "0.18.0-DEV"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
6 changes: 3 additions & 3 deletions docs/src/heaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ isempty(h) # returns whether the heap is empty

push!(h, v) # add a value to the heap

top(h) # return the top value of a heap
first(h) # return the first (top) value of a heap

pop!(h) # removes the top value, and returns it
pop!(h) # removes the first (top) value, and returns it

```

Expand Down Expand Up @@ -73,7 +73,7 @@ popmax!(h, k) # remove and return the largest k elements
popall!(h) # remove and return all the elements, sorted smallest to largest
popall!(h, o) # remove and return all the elements according to ordering o
```
The usual `top(h)` and `pop!(h)` are defined to be `minimum(h)` and `popmin!(h)`,
The usual `first(h)` and `pop!(h)` are defined to be `minimum(h)` and `popmin!(h)`,
respectively.

This package includes an implementation of a binary min-max heap (`BinaryMinMaxHeap`).
Expand Down
6 changes: 0 additions & 6 deletions src/DataStructures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ module DataStructures
export capacity, num_blocks, top_with_handle, sizehint!

export Accumulator, counter, reset!, inc!, dec!

export ClassifiedCollections
export classified_lists, classified_sets, classified_counters

export IntDisjointSets, DisjointSets, num_groups, find_root!, in_same_set, root_union!

export FenwickTree, length, inc!, dec!, incdec!, prefixsum

export AbstractHeap, compare, extract_all!
Expand Down Expand Up @@ -70,7 +65,6 @@ module DataStructures
include("stack.jl")
include("queue.jl")
include("accumulator.jl")
include("classified_collections.jl")
include("disjoint_set.jl")
include("heaps.jl")

Expand Down
55 changes: 0 additions & 55 deletions src/classified_collections.jl

This file was deleted.

3 changes: 0 additions & 3 deletions src/default_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ DefaultDictBase{K,V}(default::F; kwargs...) where {K,V,F} = DefaultDictBase{K,V,
@delegate_return_parent DefaultDictBase.d [ delete!, empty!, setindex!, sizehint! ]

empty(d::DefaultDictBase{K,V,F}) where {K,V,F} = DefaultDictBase{K,V,F}(d.default; passkey=d.passkey)
@deprecate similar(d::DefaultDictBase) empty(d)

getindex(d::DefaultDictBase, key) = get!(d.d, key, d.default)

Expand Down Expand Up @@ -144,8 +143,6 @@ for _Dict in [:Dict, :OrderedDict]

empty(d::$DefaultDict{K,V,F}) where {K,V,F} = $DefaultDict{K,V,F}(d.d.default)
in(key, v::Base.KeySet{K,T}) where {K,T<:$DefaultDict{K}} = key in keys(v.dict.d.d)

@deprecate similar(d::$DefaultDict) empty(d)
end
end

Expand Down
13 changes: 3 additions & 10 deletions src/deprecations.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
@deprecate front(x) first(x)
@deprecate back(x) last(x)
@deprecate top(x) first(x)
#@deprecate find_root find_root! # 2020-03-31 - deprecate in v0.18, or when Julia 1.5 is released.
export find_root
const find_root = find_root!

@deprecate deque(::Type{T}) where {T} Deque{T}()

@deprecate path(t::Trie, str::AbstractString) partial_path(t::Trie, str::AbstractString)
# 0.18 deprecations. Remove before releasing 0.19
@deprecate path(t::Trie, str::AbstractString) partial_path(t::Trie, str::AbstractString)
@deprecate find_root find_root!
6 changes: 3 additions & 3 deletions src/heaps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#
# - sizehint!(h, s) set size hint to a heap
#
# - top(h) return the top value of a heap
# - first(h) return the first (top) value of a heap
#
# - pop!(h) removes the top value, and
# - pop!(h) removes the first (top) value, and
# returns it
#
# For mutable heaps, it should also support
Expand Down Expand Up @@ -113,7 +113,7 @@ function nextreme(comp::Comp, n::Int, arr::AbstractVector{T}) where {T, Comp}

for i = n + 1 : length(arr)
@inbounds xi = arr[i]
if compare(comp, top(buffer), xi)
if compare(comp, first(buffer), xi)
# This could use a pushpop method
pop!(buffer)
push!(buffer, xi)
Expand Down
4 changes: 2 additions & 2 deletions src/heaps/binary_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ function sizehint!(h::BinaryHeap, s::Integer)
end

"""
top(h::BinaryHeap)
first(h::BinaryHeap)

Returns the element at the top of the heap `h`.
"""
@inline top(h::BinaryHeap) = h.valtree[1]
@inline first(h::BinaryHeap) = h.valtree[1]

pop!(h::BinaryHeap{T}) where {T} = _binary_heap_pop!(h.comparer, h.valtree)
6 changes: 3 additions & 3 deletions src/heaps/minmax_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ function push!(h::BinaryMinMaxHeap, v)
end

"""
top(h::BinaryMinMaxHeap)
first(h::BinaryMinMaxHeap)

Get the top (minimum) of the heap.
Get the first (minimum) of the heap.
"""
@inline top(h::BinaryMinMaxHeap) = minimum(h)
@inline first(h::BinaryMinMaxHeap) = minimum(h)

@inline function minimum(h::BinaryMinMaxHeap)
valtree = h.valtree
Expand Down
10 changes: 1 addition & 9 deletions src/heaps/mutable_binary_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,6 @@ const MutableBinaryMaxHeap{T} = MutableBinaryHeap{T, GreaterThan}
MutableBinaryMinHeap(xs::AbstractVector{T}) where T = MutableBinaryMinHeap{T}(xs)
MutableBinaryMaxHeap(xs::AbstractVector{T}) where T = MutableBinaryMaxHeap{T}(xs)

# deprecated constructors

@deprecate mutable_binary_minheap(::Type{T}) where {T} MutableBinaryMinHeap{T}()
@deprecate mutable_binary_minheap(xs::AbstractVector{T}) where {T} MutableBinaryMinHeap(xs)
@deprecate mutable_binary_maxheap(::Type{T}) where {T} MutableBinaryMaxHeap{T}()
@deprecate mutable_binary_maxheap(xs::AbstractVector{T}) where {T} MutableBinaryMaxHeap(xs)


function show(io::IO, h::MutableBinaryHeap)
print(io, "MutableBinaryHeap(")
nodes = h.nodes
Expand Down Expand Up @@ -227,7 +219,7 @@ function sizehint!(h::MutableBinaryHeap, s::Integer)
return h
end

@inline top(h::MutableBinaryHeap) = h.nodes[1].value
@inline first(h::MutableBinaryHeap) = h.nodes[1].value

"""
top_with_handle(h::MutableBinaryHeap)
Expand Down
2 changes: 0 additions & 2 deletions src/multi_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ empty(d::MultiDict{K,V}) where {K,V} = MultiDict{K,V}()
delete!(d::MultiDict, key) = (delete!(d.d, key); d)
empty!(d::MultiDict) = (empty!(d.d); d)

@deprecate similar(d::MultiDict) empty(d)

function insert!(d::MultiDict{K,V}, k, v) where {K,V}
if !haskey(d.d, k)
d.d[k] = V[]
Expand Down
2 changes: 0 additions & 2 deletions src/sorted_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,4 @@ empty). Time: O(1)
empty(m::SortedDict{K,D,Ord}) where {K,D,Ord<:Ordering} =
SortedDict{K,D,Ord}(orderobject(m))

@deprecate similar(m::SortedDict) empty(m)

isordered(::Type{T}) where {T<:SortedDict} = true
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ tests = ["deprecations",
"stack",
"queue",
"accumulator",
"classified_collections",
"disjoint_set",
"binheap",
"mutable_binheap",
Expand Down
4 changes: 2 additions & 2 deletions test/test_binheap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@test length(h) == 10
@test !isempty(h)
@test top(h) == 1
@test first(h) == 1
@test isequal(h.valtree, [1, 2, 3, 4, 7, 9, 10, 14, 8, 16])
@test sizehint!(h, 100) === h
end
Expand All @@ -20,7 +20,7 @@

@test length(h) == 10
@test !isempty(h)
@test top(h) == 16
@test first(h) == 16
@test isequal(h.valtree, [16, 14, 10, 8, 7, 3, 9, 1, 4, 2])
@test sizehint!(h, 100) === h
end
Expand Down
87 changes: 0 additions & 87 deletions test/test_classified_collections.jl

This file was deleted.

5 changes: 0 additions & 5 deletions test/test_deque.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,4 @@
@test typeof(empty!(q)) === typeof(Deque{Int}())
@test isempty(q)
end

@testset "deprecated constructors" begin
@test_deprecated deque(Int)
end

end # @testset Deque
6 changes: 2 additions & 4 deletions test/test_minmax_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using Base.Order: Forward, Reverse
h = BinaryMinMaxHeap(vs)
@test length(h) == 10
@test !isempty(h)
@test top(h) == minimum(h) == 1
@test first(h) == minimum(h) == 1
@test maximum(h) == 20
@test is_minmax_heap(h.valtree)
end
Expand All @@ -48,7 +48,7 @@ using Base.Order: Forward, Reverse
@test isempty(h)

push!(h, 1)
@test top(h) == 1
@test first(h) == 1
push!(h, 2)
@test is_minmax_heap(h.valtree)
push!(h, 10)
Expand Down Expand Up @@ -163,10 +163,8 @@ using Base.Order: Forward, Reverse
h = BinaryMinMaxHeap{Int}()
@test_throws ArgumentError pop!(h)
@test_throws ArgumentError popmin!(h)

@test_throws ArgumentError popmax!(h)

@test_throws ArgumentError top(h)
@test_throws ArgumentError minimum(h)
@test_throws ArgumentError maximum(h)

Expand Down
Loading