I ran into the following problem creating partitions of objects of varying
types. I'm using the DisjointSets structure found in the DataStructures
module.
This code runs fine:
using DataStructures
elements = ["alpha", "beta", "gamma", "delta"]
parts = DisjointSets{ASCIIString}(elements) # this is the line I will
alter
println("Before: number of parts is ",num_groups(parts))
union!(parts,"alpha", "beta")
println("After: number of parts is ",num_groups(parts))
The output is what I expect:
Before: number of parts is 4
After: number of parts is 3
However, if we change parts to hold objects of Any type we have a problem.
Change the assignment of parts to this:
parts = DisjointSets{Any}(elements)
Then this is what happens:
Before: number of parts is 4
ERROR: `union!` has no method matching union!(::DisjointSets{Any},
::ASCIIString, ::ASCIIString)
By the way, it doesn't help to define elements like this: elements =
{"alpha", "beta", "gamma", "delta"}
Is it necessary for union! to check/assert the types of its 2nd and 3rd
arguments??