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 Object
| Modifier and Type | Field and Description |
|---|---|
protected C |
comparatorContext |
protected 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(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() |
Object[] |
toArray()
Returns the elements of the group.
|
String |
toString() |
protected EquivalenceComparator<? super E,? super C> eqComparator
protected C comparatorContext
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(Object other)
public int hashCode()
hashCode in class ObjectObject.hashCode()public Object[] toArray()
Copyright © 2015. All Rights Reserved.