E - the element typepublic class PartiallyOrderedHashSet<E> extends AbstractSet<E> implements PartiallyOrderedSet<E>
Objects with pairwise orderings between them. The iterator method provides the elements in topologically sorted
order. Elements participating in a cycle are not returned.
Unlike the SortedSet and SortedMap interfaces, which require their elements to implement the Comparable
interface, this class receives ordering information via its setOrdering and unsetOrdering methods.
Unlike the PartiallyOrderedTreeSet, elements which do have an ordering defined by the
#setOrdering(java.lang.Comparable, java.lang.Comparable) method will be iterated with no ordering defined, as for the
HashSet class.| Constructor and Description |
|---|
PartiallyOrderedHashSet()
Constructs a
PartiallyOrderedSet. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o)
Adds an
Object to this PartiallyOrderedHashSet. |
void |
clear() |
boolean |
contains(Object o) |
boolean |
hasOrdering(E preferred,
E other)
Returns
true if an ordering exists between two elements. |
Iterator<E> |
iterator()
Returns an iterator over the elements contained in this collection, with an ordering that respects the orderings set by the
setOrdering method. |
boolean |
remove(Object o)
Removes an
Object from this PartiallyOrderedHashSet. |
boolean |
setOrdering(E first,
E second)
Sets an ordering between two elements.
|
int |
size() |
boolean |
unsetOrdering(E first,
E second)
Removes any ordering between two elements.
|
equals, hashCode, removeAlladdAll, containsAll, isEmpty, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streampublic PartiallyOrderedHashSet()
PartiallyOrderedSet.public int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>public Iterator<E> iterator()
setOrdering method.public boolean add(E o)
Object to this PartiallyOrderedHashSet.add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>o - the object to addpublic boolean remove(Object o)
Object from this PartiallyOrderedHashSet.remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>o - the object to removepublic void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>public boolean setOrdering(E first, E second)
setOrdering in interface PartiallyOrderedSet<E>first - the first elementsecond - the second elementtrue if no prior ordering existed between the elements, false otherwise.public boolean unsetOrdering(E first, E second)
unsetOrdering in interface PartiallyOrderedSet<E>first - the first elementsecond - the second elementtrue if an ordering existed between the elements.public boolean hasOrdering(E preferred, E other)
true if an ordering exists between two elements.hasOrdering in interface PartiallyOrderedSet<E>preferred - the element to considerother - the other elementtrue if there is an ordetring between the two elements