DataStructures.jl icon indicating copy to clipboard operation
DataStructures.jl copied to clipboard

Allow passing arbitrary Integers to methods for IntDisjointSets

Open simonschoelly opened this issue 3 years ago • 1 comments

I noticed that some methods for IntDisjointSets are defined such that they only allow the exact eltype as parameter, for example

"""
    in_same_set(s::IntDisjointSet{T}, x::T, y::T)
Returns `true` if `x` and `y` belong to the same subset in `s`, and `false` otherwise.
"""
in_same_set(s::IntDisjointSet{T}, x::T, y::T) where {T<:Integer} = find_root!(s, x) == find_root!(s, y)

Would be a good idea to change these methods to something like

in_same_set(s::IntDisjointSet{T}, x::Integer, y::Integer) where {T<:Integer} = find_root!(s, T(x)) == find_root!(s, T(y))

?

simonschoelly avatar Jan 15 '22 11:01 simonschoelly

yes, it would

oxinabox avatar Jan 17 '22 16:01 oxinabox