Skip to content

Commit

Permalink
Merge pull request #921 from amontoison/patch-1
Browse files Browse the repository at this point in the history
Update disjoint_set.jl
  • Loading branch information
oxinabox authored Feb 20, 2025
2 parents 2126bb5 + 4dd340c commit 1c6869c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/disjoint_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ end
IntDisjointSet(n::T) where {T<:Integer} = IntDisjointSet{T}(collect(Base.OneTo(n)), zeros(T, n), n)
IntDisjointSet{T}(n::Integer) where {T<:Integer} = IntDisjointSet{T}(collect(Base.OneTo(T(n))), zeros(T, T(n)), T(n))
Base.length(s::IntDisjointSet) = length(s.parents)
function Base.sizehint!(s::IntDisjointSet, n::Integer)
sizehint!(s.parents, n)
sizehint!(s.ranks, n)
return s
end

"""
num_groups(s::IntDisjointSet)
Expand Down Expand Up @@ -182,6 +187,7 @@ Base.empty(s::DisjointSet{T}, ::Type{U}=T) where {T,U} = DisjointSet{U}()
function Base.sizehint!(s::DisjointSet, n::Integer)
sizehint!(s.intmap, n)
sizehint!(s.revmap, n)
sizehint!(s.internal, n)
return s
end

Expand Down

0 comments on commit 1c6869c

Please sign in to comment.