Interface DisjointSetStruct
-
- All Known Implementing Classes:
HugeAtomicDisjointSetStruct
public interface DisjointSetStructDisjoint-set-struct is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets.- See Also:
- Wiki
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default LongNodePropertyValuesasNodeProperties()Wraps the DisjointSetStruct in an LongNodeProperties interfacebooleansameSet(long p, long q)Check if p and q belong to the same set.longsetIdOf(long nodeId)Find set Id of element p.longsize()Number of elements stored in the data structure.voidunion(long p, long q)Joins the set of p (Sp) with set of q (Sq).
-
-
-
Method Detail
-
union
void union(long p, long q)Joins the set of p (Sp) with set of q (Sq).- Parameters:
p- an item of Spq- an item of Sq
-
setIdOf
long setIdOf(long nodeId)
Find set Id of element p.- Parameters:
nodeId- the element in the set we are looking for- Returns:
- an id of the set it belongs to
-
sameSet
@TestOnly boolean sameSet(long p, long q)Check if p and q belong to the same set. use only in tests.- Parameters:
p- a set itemq- a set item- Returns:
- true if both items belong to the same set, false otherwise
-
size
long size()
Number of elements stored in the data structure.- Returns:
- element count
-
asNodeProperties
default LongNodePropertyValues asNodeProperties()
Wraps the DisjointSetStruct in an LongNodeProperties interface- Returns:
- wrapped DisjointSetStruct
-
-