Class UnionFind<V>
java.lang.Object
tools.refinery.interpreter.matchers.algorithms.UnionFind<V>
- Type Parameters:
V- the type parameter of the element's stored in the union-find data structure
Union-find data structure implementation. Note that the implementation relies on the correct implementation of the
equals method of the type parameter's class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDelete the set whose root is the given node.Find method with path compression.getPartition(V element) Returns the partition in which the given element can be found, or null otherwise.Collection<Set<V>> Returns all partitions.booleanisSameUnion(Set<V> elements) Returns if all given elements are in the same partition.makeSet(Collection<V> nodes) Creates a new union set from a collection of elements.This method creates a single set containing the given node.Union by rank implementation of the two sets which contain x and y; x and/or y can be a single element from the universe.voidPlaces the given elements in to the same partition.
-
Constructor Details
-
UnionFind
public UnionFind()Instantiate a new union-find data structure. -
UnionFind
-
-
Method Details
-
makeSet
Creates a new union set from a collection of elements.- Parameters:
nodes- the collection of elements- Returns:
- the root element
-
makeSet
-
find
-
union
-
unite
-
deleteSet
Delete the set whose root is the given node.- Parameters:
root- the root node
-
isSameUnion
-
getPartition
-
getPartitions
Returns all partitions. -
getPartitionHeads
-