E
- the type of the elements in the setC
- the type of the context the element is compared against, e.g. a
Graphpublic class EquivalenceSet<E,C>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected C |
comparatorContext |
protected java.util.Set<E> |
elementsSet
Contains the current elements of the group
|
protected EquivalenceComparator<? super E,? super C> |
eqComparator
The comparator used to define the group
|
Constructor and Description |
---|
EquivalenceSet(E aElement,
EquivalenceComparator<? super E,? super C> aEqComparator,
C aComparatorContext)
Constructs a new EquivalenceSet, filled with the aElement parameter and a
reference to the comparator which is used.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Adds an element to the group.
|
boolean |
equals(java.lang.Object other)
Uses the equivalenceCompare() of the comparator to compare a
representation of this group, taken using this.getRepresentative(), and a
representation of the other object, which may be the object itself, or,
if it is an equivalence group too, other.getRepresentative()
|
boolean |
equivalentTo(E aOther,
C aOtherContext) |
C |
getContext() |
E |
getRepresentative()
Returns an arbitrary object from the group.
|
int |
hashCode()
Uses a representative to calculate the group hashcode using
equivalenceHashcode().
|
int |
size() |
java.lang.Object[] |
toArray()
Returns the elements of the group.
|
java.lang.String |
toString() |
protected EquivalenceComparator<? super E,? super C> eqComparator
protected C comparatorContext
protected java.util.Set<E> elementsSet
public EquivalenceSet(E aElement, EquivalenceComparator<? super E,? super C> aEqComparator, C aComparatorContext)
public E getRepresentative()
public C getContext()
public int size()
public void add(E element)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object[] toArray()