java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.collect.DisjointSets<T> |
This type represents disjoint sets.
The following operations define what a disjoint set is:
add1
operation creates a new set with that value, unless an existing
set containing that value already exists.
add2
operation adds two "connected elements": they must reside
in the same set. If those two elements currently reside in two separate sets, those sets are
merged.
This class does not override hashCode/equals
. Internally, HashSet objects are
used. Therefore, there is no guarantee provided on elements ordering.
Objects of this class are serializable at the condition that T is serializable.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DisjointSets()
Create a new "disjoint sets" object
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
add(T v)
Create a set and add the provided value, unless a set with the value already exists.
| ||||||||||
boolean |
add(T a, T b)
Add two linked values to the same set, potentially merging two existing sets into one.
| ||||||||||
void |
clear()
Clear all sets.
| ||||||||||
int |
getCountOfValues()
Retrieve the count of elements existing in all the sets managed by this object.
| ||||||||||
Collection<Set<T>> |
getSets()
Retrieve a read-only view of the current disjoint sets managed by this object.
| ||||||||||
Set<T> |
getValues()
Retrieve the values stored in all the sets managed by this object.
| ||||||||||
boolean |
isEmpty()
Determine whether this object contains at least one set.
| ||||||||||
int |
size()
Retrieve the count of sets.
| ||||||||||
String | toString() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a new "disjoint sets" object
Create a set and add the provided value, unless a set with the value already exists.
v | a value |
---|
Add two linked values to the same set, potentially merging two existing sets into one.
a | first value |
---|---|
b | second value |
Clear all sets.
Retrieve the count of elements existing in all the sets managed by this object.
Retrieve a read-only view of the current disjoint sets managed by this object.
Retrieve the values stored in all the sets managed by this object.
Determine whether this object contains at least one set.
Retrieve the count of sets.