Skip to content

Commit 4dd340c

Browse files
authored
Update disjoint_set.jl
1 parent 07d5bb1 commit 4dd340c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/disjoint_set.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ end
3232
IntDisjointSet(n::T) where {T<:Integer} = IntDisjointSet{T}(collect(Base.OneTo(n)), zeros(T, n), n)
3333
IntDisjointSet{T}(n::Integer) where {T<:Integer} = IntDisjointSet{T}(collect(Base.OneTo(T(n))), zeros(T, T(n)), T(n))
3434
Base.length(s::IntDisjointSet) = length(s.parents)
35+
function Base.sizehint!(s::IntDisjointSet, n::Integer)
36+
sizehint!(s.parents, n)
37+
sizehint!(s.ranks, n)
38+
return s
39+
end
3540

3641
"""
3742
num_groups(s::IntDisjointSet)

0 commit comments

Comments
 (0)