PSortedSet based on a self-balancing binary search tree.
Null values are not allowed.
Instances of this class are obtained via any of various static factory methods and static collector methods. These methods come in pairs, with one version that accepts an explicit comparator to use and one version that uses the natural ordering of the elements.
All operations are guaranteed to complete within O(log n) time, except for plusAll and minusAll, whose time cost is equivalent to the corresponding sequence of calls to plus or minus. A complete iteration pass completes in O(n) time. A few operations -- namely comparator, descendingSet, isEmpty, and size -- complete in O(1) time.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final Comparator | |
| private static final long | |
| private final KVTree |
| Access | Constructor and Description |
|---|---|
| pack-priv | TreePSet(final KVTree<E, ?> tree, final Comparator<? super E> ltrComparator, final boolean isLeftToRight)
Non-private only because also used by TreePMap.keySet(). |
| Modifier and Type | Method and Description |
|---|---|
| public E | ceiling(final E
the value to match e)Implements java. Returns the least element in this set greater than or equal to
the given element, or |
| public Comparator | comparator()
Implements org. Returns the comparator used to order the elements in this set,
or |
| public boolean | contains(final Object
element whose presence in this set is to be tested e)Overrides java. Implements java. Returns |
| public Iterator | descendingIterator()
Implements java. Returns an iterator over the elements in this set, in descending order. |
| public TreePSet | descendingSet()
Implements org. Returns a reverse order view of the elements contained in this set. |
| public static < the type of elements to be maintained by the set E extends Comparable | Returns: an empty TreePSet using the natural orderingReturns an empty TreePSet using the natural ordering. |
| public static < the type of elements to be maintained by the set E> TreePSet | Returns: an empty TreePSet using the specified comparatorthe comparator according to which elements should be ordered comparator)Returns an empty TreePSet using the specified comparator. |
| public E | first()
Implements java. Returns the first (lowest) element currently in this set. |
| public E | floor(final E
the value to match e)Implements java. Returns the greatest element in this set less than or equal to
the given element, or |
| public static < the type of elements to be maintained by the set E extends Comparable | Returns: a TreePSet containing the elements of list and using the natural orderingthe elements to include list)Returns a TreePSet with the specified elements, using their natural ordering. |
| public static < the type of elements to be maintained by the set E> TreePSet | Returns: a TreePSet with the specified comparator and elementsthe comparator to use comparator, final Collection<? extends E> the collection of elements to include; may include duplicates, but the returned
TreePSet will not list)Returns a TreePSet with the specified comparator and elements. |
| public static < the type of elements to be maintained by the set E> TreePSet | Returns: a TreePSet with the same elements and ordering as the specified setthe set whose elements and ordering to use set)Returns a TreePSet with the same elements and ordering as the specified set. |
| public TreePSet | headSet(final E
high endpoint (exclusive) of the returned set toElement)Implements org. Returns a view of the portion of this set whose elements are
strictly less than |
| public TreePSet | headSet(final E
high endpoint of the returned set toElement, final boolean true if the high endpoint
is to be included in the returned viewImplements org. Returns a view of the portion of this set whose elements are less than
(or equal to, if |
| public E | higher(final E
the value to match e)Implements java. Returns the least element in this set strictly greater than the
given element, or |
| public TreePSet | |
| public Iterator | iterator()
Implements abstract java. Implements java. Returns an iterator over the elements in this set, in ascending order. |
| public E | last()
Implements java. Returns the last (highest) element currently in this set. |
| public E | lower(final E
the value to match e)Implements java. Returns the greatest element in this set strictly less than the
given element, or |
| public TreePSet | |
| public TreePSet | |
| public TreePSet | |
| public TreePSet | |
| public static < the type of elements to be maintained by the set E extends Comparable | Returns: a TreePSet containing the specified elements and using their natural orderingthe elements to include; may include duplicates, but the returned TreePSet will
not elements)Hides java. Returns a TreePSet with the specified elements, using their natural ordering. |
| public static < the type of elements to be maintained by the set E> TreePSet | Returns: a TreePSet containing the specified elements and using the specified comparatorthe comparator to use comparator, final E... the elements to include; may include duplicates, but the returned TreePSet will
not elements)Hides java. Returns a TreePSet with the specified comparator and elements. |
| public TreePSet | |
| public TreePSet | |
| private E | search(final E e, final KVTree.
|
| public static < the type of elements to be maintained by the set E extends Comparable | Returns: a TreePSet containing the specified element and using the natural orderingthe element e)Returns a TreePSet with a single element, using the natural ordering. |
| public static < the type of elements to be maintained by the set E> TreePSet | Returns: a TreePSet containing the specified element and using the specified comparatorthe comparator according to which elements should be ordered comparator, final E the element e)Returns a TreePSet with a single element, using the specified comparator. |
| public int | size()
Implements abstract java. Implements java. Returns the number of elements in this set (its cardinality). |
| private static <T> T | |
| public TreePSet | subSet(final E
low endpoint (inclusive) of the returned set fromElement, final E high endpoint (exclusive) of the returned set toElement)Implements org. Returns a view of the portion of this set whose elements range
from |
| public TreePSet | subSet(final E
low endpoint of the returned set fromElement, final boolean true if the low endpoint
is to be included in the returned viewhigh endpoint of the returned set toElement, final boolean true if the high endpoint
is to be included in the returned viewImplements org. Returns a view of the portion of this set whose elements range from
|
| public TreePSet | tailSet(final E
low endpoint (inclusive) of the returned set fromElement)Implements org. Returns a view of the portion of this set whose elements are
greater than or equal to |
| public TreePSet | tailSet(final E
low endpoint of the returned set fromElement, final boolean true if the low endpoint
is to be included in the returned viewImplements org. Returns a view of the portion of this set whose elements are greater
than (or equal to, if |
| public static < the type of elements to be maintained by the set E extends Comparable | Returns: a collector that gathers the elements of the stream into a TreePSet that uses the natural orderingReturns a collector that gathers a stream into a TreePSet with the elements of that stream, using their natural ordering. |
| public static < the type of elements to be maintained by the set E> Collector | Returns: a collector that gathers the elements of the stream into a TreePSet that uses the specified comparatorthe comparator to use comparator)Returns a collector that gathers a stream into a TreePSet with the elements of that stream, using the specified comparator. |
| private TreePSet |
| isLeftToRight | back to summary |
|---|---|
| private final boolean isLeftToRight | |
| ltrComparator | back to summary |
|---|---|
| private final Comparator<? super E> ltrComparator | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| tree | back to summary |
|---|---|
| private final KVTree<E, ?> tree | |
| TreePSet | back to summary |
|---|---|
| pack-priv TreePSet(final KVTree<E, ?> tree, final Comparator<? super E> ltrComparator, final boolean isLeftToRight) Non-private only because also used by TreePMap.keySet(). No other code should use it from outside this class. | |
| ceiling | back to summary |
|---|---|
| public E ceiling(final E e) Implements java. Doc from java. Returns the least element in this set greater than or equal to
the given element, or
| |
| comparator | back to summary |
|---|---|
| public Comparator Implements org. Doc from java. Returns the comparator used to order the elements in this set,
or
| |
| contains | back to summary |
|---|---|
| public boolean contains(final Object e) Overrides java. Implements java. Doc from java. Returns | |
| descendingIterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over the elements in this set, in descending order.
Equivalent in effect to | |
| descendingSet | back to summary |
|---|---|
| public TreePSet Implements org. Doc from java. Returns a reverse order view of the elements contained in this set.
The descending set is backed by this set, so changes to the set are
reflected in the descending set, and vice-versa. If either set is
modified while an iteration over either set is in progress (except
through the iterator's own The returned set has an ordering equivalent to
| |
| empty | back to summary |
|---|---|
| public static <E extends Comparable Returns an empty TreePSet using the natural ordering.
| |
| empty | back to summary |
|---|---|
| public static <E> TreePSet Returns an empty TreePSet using the specified comparator.
| |
| first | back to summary |
|---|---|
| public E first() Implements java. Doc from java. Returns the first (lowest) element currently in this set.
| |
| floor | back to summary |
|---|---|
| public E floor(final E e) Implements java. Doc from java. Returns the greatest element in this set less than or equal to
the given element, or
| |
| from | back to summary |
|---|---|
| public static <E extends Comparable Returns a TreePSet with the specified elements, using their natural ordering.
| |
| from | back to summary |
|---|---|
| public static <E> TreePSet Returns a TreePSet with the specified comparator and elements.
| |
| fromSortedSet | back to summary |
|---|---|
| public static <E> TreePSet Returns a TreePSet with the same elements and ordering as the specified set. This is
essentially equivalent to
| |
| headSet | back to summary |
|---|---|
| public TreePSet Implements org. Doc from java. Returns a view of the portion of this set whose elements are
strictly less than The returned set will throw an Equivalent to
| |
| headSet | back to summary |
|---|---|
| public TreePSet Implements org. Doc from java. Returns a view of the portion of this set whose elements are less than
(or equal to, if The returned set will throw an | |
| higher | back to summary |
|---|---|
| public E higher(final E e) Implements java. Doc from java. Returns the least element in this set strictly greater than the
given element, or
| |
| intersect | back to summary |
|---|---|
| public TreePSet Overrides default org.
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. Returns an iterator over the elements in this set, in ascending order. | |
| last | back to summary |
|---|---|
| public E last() Implements java. Doc from java. Returns the last (highest) element currently in this set.
| |
| lower | back to summary |
|---|---|
| public E lower(final E e) Implements java. Doc from java. Returns the greatest element in this set strictly less than the
given element, or
| |
| minus | back to summary |
|---|---|
| public TreePSet Implements org.
| |
| minusAll | back to summary |
|---|---|
| public TreePSet Implements org.
| |
| minusFirst | back to summary |
|---|---|
| public TreePSet Implements org.
| |
| minusLast | back to summary |
|---|---|
| public TreePSet Implements org.
| |
| of | back to summary |
|---|---|
| public static <E extends Comparable Hides java. Returns a TreePSet with the specified elements, using their natural ordering.
| |
| of | back to summary |
|---|---|
| public static <E> TreePSet Hides java. Returns a TreePSet with the specified comparator and elements.
| |
| plus | back to summary |
|---|---|
| public TreePSet Implements org.
| |
| plusAll | back to summary |
|---|---|
| public TreePSet Implements org.
| |
| search | back to summary |
|---|---|
| private E search(final E e, final KVTree. | |
| singleton | back to summary |
|---|---|
| public static <E extends Comparable Returns a TreePSet with a single element, using the natural ordering.
| |
| singleton | back to summary |
|---|---|
| public static <E> TreePSet Returns a TreePSet with a single element, using the specified comparator.
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| sneakilyDowncast | back to summary |
|---|---|
private static <T> T sneakilyDowncast(final Object o)
| |
| subSet | back to summary |
|---|---|
| public TreePSet Implements org. Doc from java. Returns a view of the portion of this set whose elements range
from The returned set will throw an Equivalent to
| |
| subSet | back to summary |
|---|---|
| public TreePSet Implements org. Doc from java. Returns a view of the portion of this set whose elements range from
The returned set will throw an
| |
| tailSet | back to summary |
|---|---|
| public TreePSet Implements org. Doc from java. Returns a view of the portion of this set whose elements are
greater than or equal to The returned set will throw an Equivalent to
| |
| tailSet | back to summary |
|---|---|
| public TreePSet Implements org. Doc from java. Returns a view of the portion of this set whose elements are greater
than (or equal to, if The returned set will throw an | |
| toTreePSet | back to summary |
|---|---|
| public static <E extends Comparable Returns a collector that gathers a stream into a TreePSet with the elements of that stream, using their natural ordering. | |
| toTreePSet | back to summary |
|---|---|
| public static <E> Collector Returns a collector that gathers a stream into a TreePSet with the elements of that stream, using the specified comparator.
| |
| withTree | back to summary |
|---|---|
| private TreePSet | |