We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
BitSet
count_unique
1 parent ead687e commit d5e0e37Copy full SHA for d5e0e37
src/connectivity.jl
@@ -197,7 +197,7 @@ function count_unique(label::Vector{T}) where {T}
197
# effectively does `length(Set(label))` but faster, since `Set(label)` sizehints
198
# aggressively and assumes that most elements of `label` will be unique, which very
199
# rarely will be the case for caller `count_connected_components!`
200
- seen = Set{T}()
+ seen = T === Int ? BitSet() : Set{T}() # if `T=Int`, we can use faster BitSet
201
for l in label
202
# faster than direct `push!(seen, l)` when `label` has few unique elements relative
203
# to `length(label)`
0 commit comments