E - the element typepublic class PartiallyOrderedTreeSet<E extends Comparable> 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 PartiallyOrderedHashSet, elements which do have an ordering defined by the
setOrdering(java.lang.Comparable, java.lang.Comparable) method will be iterated through their natural ordering, as for the
TreeSet class.| Constructor and Description |
|---|
PartiallyOrderedTreeSet()
Constructs a
PartiallyOrderedTreeSet. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o)
Adds an
Object to this PartiallyOrderedSet. |
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 PartiallyOrderedSet. |
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 PartiallyOrderedTreeSet()
PartiallyOrderedTreeSet. The elements which are not explictly ordered will be sorted according to their natural
order.public int size()
size in interface Collection<E extends Comparable>size in interface Set<E extends Comparable>size in class AbstractCollection<E extends Comparable>public boolean contains(Object o)
contains in interface Collection<E extends Comparable>contains in interface Set<E extends Comparable>contains in class AbstractCollection<E extends Comparable>public Iterator<E> iterator()
setOrdering method.iterator in interface Iterable<E extends Comparable>iterator in interface Collection<E extends Comparable>iterator in interface Set<E extends Comparable>iterator in class AbstractCollection<E extends Comparable>public boolean add(E o)
Object to this PartiallyOrderedSet.add in interface Collection<E extends Comparable>add in interface Set<E extends Comparable>add in class AbstractCollection<E extends Comparable>public boolean remove(Object o)
Object from this PartiallyOrderedSet.remove in interface Collection<E extends Comparable>remove in interface Set<E extends Comparable>remove in class AbstractCollection<E extends Comparable>public void clear()
clear in interface Collection<E extends Comparable>clear in interface Set<E extends Comparable>clear in class AbstractCollection<E extends Comparable>public boolean setOrdering(E first, E second)
setOrdering in interface PartiallyOrderedSet<E extends Comparable>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 extends Comparable>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 extends Comparable>preferred - the element to considerother - the other elementtrue if there is an ordetring between the two elements