Class Partition<E>
java.lang.Object
fr.inria.rules.integraal.model.partition.Partition<E>
- Type Parameters:
E- the type of elements of the partition
- Direct Known Subclasses:
TermPartition
Partition of a set of elements maintained with a union-find structure.
- Author:
- Guillaume Pérution-Kihli
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty PartitionCreates a new Partition copying the given onePartition(Partition<E> toCopy, Comparator<E> comparator) Creates a new Partition copying the given one but overriding its comparatorPartition(Collection<Set<E>> partition) Creates a new Partition with the given classesPartition(Collection<Set<E>> partition, Comparator<E> comparator) Creates a new Partition with the given classes and comparatorPartition(Comparator<E> comparator) Creates a new empty Partition with the given comparatorCreates a new Partition with the given elements, each in its own classPartition(Set<E> initialElements, Comparator<E> comparator) Creates a new Partition with the given elements and comparator -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a class to the partition If there are some common elements with existing classes, the class will be merged with these existing classesbooleanprotected voidErase the memoized valuesReturns an immutable Set containing all the class' elements of xReturn all the classes of the partitionReturn all the elements contained in the partitionReturns a class' representative of x If x is not in the partition, the method returns an empty optional The returned representative is always the same if the partition is not modifiedinthashCode()booleanisEmpty()Indicates whether this partition contains no elements.voidJoin the class of another partition This operation consists of merge the classes of this partition and the other one when they share a common elementtoString()voidMerge the classes of x and y If x or y are not yet in the partition, they are be added to it
-
Constructor Details
-
Partition
public Partition()Creates a new empty Partition -
Partition
Creates a new empty Partition with the given comparator- Parameters:
comparator- the comparator to choose the representative of a class
-
Partition
-
Partition
Creates a new Partition with the given elements and comparator- Parameters:
initialElements- the initial elements of this partitioncomparator- the comparator to choose the representative of a class
-
Partition
Creates a new Partition with the given classes- Parameters:
partition- the initial elements represented as multiple partitions
-
Partition
Creates a new Partition with the given classes and comparator- Parameters:
partition- the initial elements represented as multiple partitionscomparator- the comparator to choose the representative of a class
-
Partition
-
Partition
Creates a new Partition copying the given one but overriding its comparator- Parameters:
toCopy- partition to copycomparator- the comparator to choose the representative of a class
-
-
Method Details
-
addClass
-
getRepresentative
Returns a class' representative of x If x is not in the partition, the method returns an empty optional The returned representative is always the same if the partition is not modified- Parameters:
x- : the element from which we want the class' representative- Returns:
- a class' representative of x or an empty optional if x is not in the partition
-
getClass
-
union
-
join
-
getClasses
-
getElements
-
hashCode
-
equals
-
toString
-
eraseMemoizedValues
protected void eraseMemoizedValues()Erase the memoized values -
isEmpty
public boolean isEmpty()Indicates whether this partition contains no elements.- Returns:
trueif the partition is empty
-