|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.javascript.jscomp.graph.StandardUnionFind<E>
E
- element typepublic class StandardUnionFind<E>
A Union-Find implementation.
This class implements Union-Find algorithm with rank and path compression.
See algorithmist for more detail.
Constructor Summary | |
---|---|
StandardUnionFind()
Creates an empty UnionFind structure. |
|
StandardUnionFind(UnionFind<E> other)
Creates an UnionFind structure being a copy of other structure. |
Method Summary | |
---|---|
void |
add(E e)
Adds the given element to a new set if it is not already in a set. |
Collection<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. |
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 . |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StandardUnionFind()
public StandardUnionFind(UnionFind<E> other)
other
- structure to be copiedMethod Detail |
---|
public void add(E e)
UnionFind
add
in interface UnionFind<E>
public E union(E a, E b)
UnionFind
a
and b
and returns the
representative of the resulting equivalence class. The elements will be
added if they are not already present.
union
in interface UnionFind<E>
public E find(E e)
UnionFind
e
.
find
in interface UnionFind<E>
public boolean areEquivalent(E a, E b)
UnionFind
a
and b
belong to the same equivalence
class.
areEquivalent
in interface UnionFind<E>
public Set<E> elements()
UnionFind
elements
in interface UnionFind<E>
public Collection<Set<E>> allEquivalenceClasses()
UnionFind
allEquivalenceClasses
in interface UnionFind<E>
public Set<E> findAll(E value)
UnionFind
value
.
findAll
in interface UnionFind<E>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |