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 DisjointSet constructor taking splatted elements #578

Closed
wants to merge 1 commit into from
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.
Jump to
Jump to file
Failed to load files.
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.10"
version = "0.18.0-DEV"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
4 changes: 3 additions & 1 deletion src/DataStructures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ module DataStructures

export findkey

include("deprecations.jl")
include("delegate.jl")

include("deque.jl")
Expand Down Expand Up @@ -107,4 +106,7 @@ module DataStructures
include("priorityqueue.jl")
include("sparse_int_set.jl")
export SparseIntSet


include("deprecations.jl")
end
2 changes: 1 addition & 1 deletion src/deprecations.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@deprecate front(x) first(x)
@deprecate back(x) last(x)
@deprecate top(x) first(x)
@deprecate top(x) first(x)
4 changes: 1 addition & 3 deletions src/disjoint_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mutable struct DisjointSets{T} <: AbstractSet{T}
internal::IntDisjointSets

DisjointSets{T}() where T = new{T}(Dict{T,Int}(), Vector{T}(), IntDisjointSets(0))
function DisjointSets{T}(xs) where T # xs must be iterable
function DisjointSets{T}(xs) where T # xs must be iterable
imap = Dict{T,Int}()
rmap = Vector{T}()
n = length(xs)
Expand All @@ -154,8 +154,6 @@ mutable struct DisjointSets{T} <: AbstractSet{T}
end

DisjointSets() = DisjointSets{Any}()
DisjointSets(xs::T...) where T = DisjointSets{T}(xs)
DisjointSets{T}(xs::T...) where T = DisjointSets{T}(xs)
DisjointSets(xs) = _DisjointSets(xs, Base.IteratorEltype(xs))
_DisjointSets(xs, ::Base.HasEltype) = DisjointSets{eltype(xs)}(xs)
function _DisjointSets(xs, ::Base.EltypeUnknown)
Expand Down
9 changes: 7 additions & 2 deletions test/test_disjoint_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@
@testset "constructor" begin
@test DisjointSets() isa DisjointSets{Any}
@test DisjointSets{Int}(1:10) isa DisjointSets{Int}
@test DisjointSets{Float64}(1.0:10.0...) isa DisjointSets{Float64}
@test DisjointSets{Float64}(1.0:10.0) isa DisjointSets{Float64}
@test DisjointSets(collect(1:10)) isa DisjointSets{Int}
@test DisjointSets(collect(1.0:10.0)...) isa DisjointSets{Float64}
@test DisjointSets(collect(1.0:10.0)) isa DisjointSets{Float64}
@test DisjointSets(x*im for x = 1:10) isa DisjointSets{Complex{Int}}
g = (x % 2 == 0 ? x+1//x : x*im for x = 1:10)
@test DisjointSets(g) isa DisjointSets{Number}

# https://github.com/JuliaCollections/DataStructures.jl/issues/570
@test DisjointSets(Any[1,2,3]) isa DisjointSets
@test DisjointSets{Any}(Any[1,2,3]) isa DisjointSets{Any}
@test DisjointSets{Int}(Any[1,2,3]) isa DisjointSets{Int}
end

@testset "basic tests" begin
Expand Down