E
- element type@GwtCompatible
public interface UnionFind<E>
Each equivalence class has a representative element that is chosen arbitrarily and is used to determine if two elements are members of the same class.
See algorithmist for more detail.
Modifier and Type | Method and Description |
---|---|
void |
add(E e)
Adds the given element to a new set if it is not already in a set.
|
java.util.Collection<java.util.Set<E>> |
allEquivalenceClasses()
Returns an immutable collection containing all equivalence classes.
|
boolean |
areEquivalent(E a,
E b)
Returns true if
a and b belong to the same equivalence
class. |
java.util.Set<E> |
elements()
Returns an unmodifiable set of all elements added to the UnionFind.
|
E |
find(E e)
Returns the representative of the equivalence class of
e . |
java.util.Set<E> |
findAll(E value)
Returns the elements in the same equivalence class as
value . |
E |
union(E a,
E b)
Unions the equivalence classes of
a and b and returns the representative of the
resulting equivalence class. |
void add(E e)
java.lang.UnsupportedOperationException
- if the add operation is not
supported by this union-find.E union(E a, E b)
a
and b
and returns the representative of the
resulting equivalence class. The elements will be added if they are not already present.java.lang.UnsupportedOperationException
- if the add operation is not supported by this union-find.boolean areEquivalent(E a, E b)
a
and b
belong to the same equivalence
class.java.lang.IllegalArgumentException
- if any argument is not an element of this
structure.java.util.Set<E> elements()
java.util.Collection<java.util.Set<E>> allEquivalenceClasses()
java.util.Set<E> findAll(E value)
value
.java.lang.IllegalArgumentException
- if a requested element does not belong
to the structure.Copyright © 2009-2018 Google. All Rights Reserved.