public interface IntDisjointSets
| Modifier and Type | Method and Description |
|---|---|
default boolean |
equivalent(int x,
int y)
Checks if two elements are in the same set.
|
int |
find(int x)
Determines the representative element of the set containing
x. |
int |
link(int rx,
int ry)
Links (unites) two sets, identified by their representatives.
|
int |
size()
Returns the size of the universe.
|
default boolean |
union(int x,
int y)
Unites the sets containing the respective elements.
|
int size()
0 (inclusive) and
size() (exclusive).default boolean equivalent(int x,
int y)
x - the first elementy - the second elementtrue if x and y are in the same set, false otherwiseint find(int x)
x.x - the element to findx.default boolean union(int x,
int y)
true. Otherwise, if x and y were already in the same set, false is returned.
Attention: this method returns true if and only if equivalent(x, y) would have returned
false.
x - the first elementy - the second elementtrue if two disjoint sets have been united as a result, false otherwiseint link(int rx,
int ry)
rx - the representative of the first setry - the representative of the second setrx or ry).Copyright © 2020. All rights reserved.