Skip to content

Commit 5c7df3d

Browse files
authored
Update disjoint_set.jl
Improve `sizehint!(DisjointSets)` such that we preallocate the vectors needed by the internal `IntDisjointSets`.
1 parent 77e5ea0 commit 5c7df3d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/disjoint_set.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ Base.empty(s::DisjointSet{T}, ::Type{U}=T) where {T,U} = DisjointSet{U}()
182182
function Base.sizehint!(s::DisjointSet, n::Integer)
183183
sizehint!(s.intmap, n)
184184
sizehint!(s.revmap, n)
185+
sizehint!(s.internal.parents, n)
186+
sizehint!(s.internal.ranks, n)
185187
return s
186188
end
187189

0 commit comments

Comments
 (0)