Skip to content

Commit

Permalink
Update disjoint_set.jl
Browse files Browse the repository at this point in the history
Improve `sizehint!(DisjointSets)` such that we preallocate the vectors needed by the internal `IntDisjointSets`.
  • Loading branch information
amontoison authored Feb 12, 2025
1 parent 77e5ea0 commit 5c7df3d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/disjoint_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ 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.parents, n)
sizehint!(s.internal.ranks, n)
return s
end

Expand Down

0 comments on commit 5c7df3d

Please sign in to comment.