Top Description Fields Constructors Methods
org.pcollections

public final Class TreePSet<E>

extends AbstractUnmodifiableSet<E>
implements PSortedSet<E>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.pcollections.PSortedSet, java.util.NavigableSet, java.util.SortedSet, java.util.SequencedSet, java.util.Set, java.util.Collection, java.lang.Iterable, java.util.SequencedCollection, org.pcollections.PSet, org.pcollections.PCollection
Type Parameters
<E>
the type of elements maintained by this set
Static Imports
java.util.Objects.requireNonNull

An implementation of 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.

Author
Ran Ari-Gur
Since
3.2.0

Field Summary

Modifier and TypeField and Description
private final boolean
private final Comparator<? super E>
private static final long
private final KVTree<E, ?>

Constructor Summary

AccessConstructor 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().

Method Summary

Modifier and TypeMethod and Description
public E
ceiling(final E
the value to match
e
)

Implements java.util.NavigableSet.ceiling.

Returns the least element in this set greater than or equal to the given element, or null if there is no such element.

public Comparator<? super E>
comparator()

Implements org.pcollections.PSortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.

public boolean
contains(final Object
element whose presence in this set is to be tested
e
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains, java.util.Set.contains.

Returns true if this set contains the specified element.

public Iterator<E>
descendingIterator()

Implements java.util.NavigableSet.descendingIterator.

Returns an iterator over the elements in this set, in descending order.

public TreePSet<E>
descendingSet()

Implements org.pcollections.PSortedSet.descendingSet.

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<? super E>
>
TreePSet<E>

Returns:

an empty TreePSet using the natural ordering
empty
()

Returns an empty TreePSet using the natural ordering.

public static <
the type of elements to be maintained by the set
E
>
TreePSet<E>

Returns:

an empty TreePSet using the specified comparator
empty
(final Comparator<? super E>
the comparator according to which elements should be ordered
comparator
)

Returns an empty TreePSet using the specified comparator.

public E
first()

Implements java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.

public E
floor(final E
the value to match
e
)

Implements java.util.NavigableSet.floor.

Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.

public static <
the type of elements to be maintained by the set
E extends Comparable<? super E>
>
TreePSet<E>

Returns:

a TreePSet containing the elements of list and using the natural ordering
from
(final Collection<? extends E>
the 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<E>

Returns:

a TreePSet with the specified comparator and elements
from
(final Comparator<? super E>
the 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<E>

Returns:

a TreePSet with the same elements and ordering as the specified set
fromSortedSet
(final SortedSet<E>
the set whose elements and ordering to use
set
)

Returns a TreePSet with the same elements and ordering as the specified set.

public TreePSet<E>
headSet(final E
high endpoint (exclusive) of the returned set
toElement
)

Implements org.pcollections.PSortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement.

public TreePSet<E>
headSet(final E
high endpoint of the returned set
toElement
,
final boolean
true if the high endpoint is to be included in the returned view
inclusive
)

Implements org.pcollections.PSortedSet.headSet.

Returns a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement.

public E
higher(final E
the value to match
e
)

Implements java.util.NavigableSet.higher.

Returns the least element in this set strictly greater than the given element, or null if there is no such element.

public TreePSet<E>
intersect(Collection<? extends E> list)

Overrides default org.pcollections.PSortedSet.intersect.

public Iterator<E>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator, java.util.Set.iterator, java.util.NavigableSet.iterator.

Returns an iterator over the elements in this set, in ascending order.

public E
last()

Implements java.util.SortedSet.last.

Returns the last (highest) element currently in this set.

public E
lower(final E
the value to match
e
)

Implements java.util.NavigableSet.lower.

Returns the greatest element in this set strictly less than the given element, or null if there is no such element.

public TreePSet<E>
public TreePSet<E>
public TreePSet<E>
public TreePSet<E>
public static <
the type of elements to be maintained by the set
E extends Comparable<? super E>
>
TreePSet<E>

Returns:

a TreePSet containing the specified elements and using their natural ordering
of
(final E...
the elements to include; may include duplicates, but the returned TreePSet will not
elements
)

Hides java.util.Set.of, java.util.Set.of.

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<E>

Returns:

a TreePSet containing the specified elements and using the specified comparator
of
(final Comparator<? super E>
the comparator to use
comparator
,
final E...
the elements to include; may include duplicates, but the returned TreePSet will not
elements
)

Hides java.util.Set.of.

Returns a TreePSet with the specified comparator and elements.

public TreePSet<E>
plus(final E e)

Implements org.pcollections.PSortedSet.plus.

public TreePSet<E>
plusAll(final Collection<? extends E> list)

Implements org.pcollections.PSortedSet.plusAll.

private E
search(final E e, final KVTree.SearchType searchTypeIfLeftToRight, final KVTree.SearchType searchTypeIfRightToLeft)

public static <
the type of elements to be maintained by the set
E extends Comparable<? super E>
>
TreePSet<E>

Returns:

a TreePSet containing the specified element and using the natural ordering
singleton
(final E
the 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<E>

Returns:

a TreePSet containing the specified element and using the specified comparator
singleton
(final Comparator<? super E>
the 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.util.AbstractCollection.size.

Implements java.util.Collection.size, java.util.Set.size.

Returns the number of elements in this set (its cardinality).

private static <T> T
public TreePSet<E>
subSet(final E
low endpoint (inclusive) of the returned set
fromElement
,
final E
high endpoint (exclusive) of the returned set
toElement
)

Implements org.pcollections.PSortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.

public TreePSet<E>
subSet(final E
low endpoint of the returned set
fromElement
,
final boolean
true if the low endpoint is to be included in the returned view
fromInclusive
,
final E
high endpoint of the returned set
toElement
,
final boolean
true if the high endpoint is to be included in the returned view
toInclusive
)

Implements org.pcollections.PSortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement to toElement.

public TreePSet<E>
tailSet(final E
low endpoint (inclusive) of the returned set
fromElement
)

Implements org.pcollections.PSortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement.

public TreePSet<E>
tailSet(final E
low endpoint of the returned set
fromElement
,
final boolean
true if the low endpoint is to be included in the returned view
inclusive
)

Implements org.pcollections.PSortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) fromElement.

public static <
the type of elements to be maintained by the set
E extends Comparable<? super E>
>
Collector<E, ?, TreePSet<E>>

Returns:

a collector that gathers the elements of the stream into a TreePSet that uses the natural ordering
toTreePSet
()

Returns 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<E, ?, TreePSet<E>>

Returns:

a collector that gathers the elements of the stream into a TreePSet that uses the specified comparator
toTreePSet
(final Comparator<? super E>
the 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<E>
withTree(final KVTree<E, ?> tree)

Inherited from org.pcollections.AbstractUnmodifiableSet:
addaddAllclearremoveremoveAllremoveIfretainAll

Field Detail

isLeftToRightback to summary
private final boolean isLeftToRight
ltrComparatorback to summary
private final Comparator<? super E> ltrComparator
serialVersionUIDback to summary
private static final long serialVersionUID
treeback to summary
private final KVTree<E, ?> tree

Constructor Detail

TreePSetback 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.

Method Detail

ceilingback to summary
public E ceiling(final E e)

Implements java.util.NavigableSet.ceiling.

Doc from java.util.NavigableSet.ceiling.

Returns the least element in this set greater than or equal to the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the least element greater than or equal to e, or null if there is no such element

Annotations
@Override
comparatorback to summary
public Comparator<? super E> comparator()

Implements org.pcollections.PSortedSet.comparator.

Doc from java.util.SortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.

Returns:Comparator<? super E>

Doc from org.pcollections.PSortedSet.comparator.

The comparator used to order the elements in this set. May be null if this set uses the natural ordering of its elements, though in that case the implementations provided by this library (pcollections) return a Comparator instance that implements the natural ordering.

Annotations
@Override
containsback to summary
public boolean contains(final Object e)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains, java.util.Set.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
e:Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

Annotations
@Override
descendingIteratorback to summary
public Iterator<E> descendingIterator()

Implements java.util.NavigableSet.descendingIterator.

Doc from java.util.NavigableSet.descendingIterator.

Returns an iterator over the elements in this set, in descending order. Equivalent in effect to descendingSet().iterator().

Returns:Iterator<E>

an iterator over the elements in this set, in descending order

Annotations
@Override
descendingSetback to summary
public TreePSet<E> descendingSet()

Implements org.pcollections.PSortedSet.descendingSet.

Doc from java.util.NavigableSet.descendingSet.

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 remove operation), the results of the iteration are undefined.

The returned set has an ordering equivalent to Collections.reverseOrder(comparator()). The expression s.descendingSet().descendingSet() returns a view of s essentially equivalent to s.

Returns:TreePSet<E>

a reverse order view of this set

Annotations
@Override
emptyback to summary
public static <E extends Comparable<? super E>> TreePSet<E> empty()

Returns an empty TreePSet using the natural ordering.

Parameters
<E>
the type of elements to be maintained by the set
Returns:TreePSet<E>

an empty TreePSet using the natural ordering

emptyback to summary
public static <E> TreePSet<E> empty(final Comparator<? super E> comparator)

Returns an empty TreePSet using the specified comparator.

Parameters
<E>
the type of elements to be maintained by the set
comparator:Comparator<? super E>

the comparator according to which elements should be ordered

Returns:TreePSet<E>

an empty TreePSet using the specified comparator

Exceptions
NullPointerException:
if comparator is null
firstback to summary
public E first()

Implements java.util.SortedSet.first.

Doc from java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.

Returns:E

the first (lowest) element currently in this set

Annotations
@Override
floorback to summary
public E floor(final E e)

Implements java.util.NavigableSet.floor.

Doc from java.util.NavigableSet.floor.

Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the greatest element less than or equal to e, or null if there is no such element

Annotations
@Override
fromback to summary
public static <E extends Comparable<? super E>> TreePSet<E> from(final Collection<? extends E> list)

Returns a TreePSet with the specified elements, using their natural ordering.

Parameters
<E>
the type of elements to be maintained by the set
list:Collection<? extends E>

the elements to include

Returns:TreePSet<E>

a TreePSet containing the elements of list and using the natural ordering

Exceptions
NullPointerException:
if list is null or contains null
fromback to summary
public static <E> TreePSet<E> from(final Comparator<? super E> comparator, final Collection<? extends E> list)

Returns a TreePSet with the specified comparator and elements.

Parameters
<E>
the type of elements to be maintained by the set
comparator:Comparator<? super E>

the comparator to use

list:Collection<? extends E>

the collection of elements to include; may include duplicates, but the returned TreePSet will not

Returns:TreePSet<E>

a TreePSet with the specified comparator and elements

Exceptions
NullPointerException:
if the comparator is null or the collection is or contains null
fromSortedSetback to summary
public static <E> TreePSet<E> fromSortedSet(final SortedSet<E> set)

Returns a TreePSet with the same elements and ordering as the specified set. This is essentially equivalent to TreePSet.from(set.comparator(), set), except that it gracefully handles a null comparator, and is much more efficient.

Parameters
<E>
the type of elements to be maintained by the set
set:SortedSet<E>

the set whose elements and ordering to use

Returns:TreePSet<E>

a TreePSet with the same elements and ordering as the specified set

Exceptions
NullPointerException:
if the specified set is or contains null
headSetback to summary
public TreePSet<E> headSet(final E toElement)

Implements org.pcollections.PSortedSet.headSet.

Doc from java.util.NavigableSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Equivalent to headSet(toElement, false).

Parameters
toElement:E

Doc from java.util.SortedSet.headSet.

high endpoint (exclusive) of the returned set

Returns:TreePSet<E>

Doc from java.util.SortedSet.headSet.

a view of the portion of this set whose elements are strictly less than toElement

Annotations
@Override
headSetback to summary
public TreePSet<E> headSet(final E toElement, final boolean inclusive)

Implements org.pcollections.PSortedSet.headSet.

Doc from java.util.NavigableSet.headSet.

Returns a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
toElement:E

high endpoint of the returned set

inclusive:boolean

true if the high endpoint is to be included in the returned view

Returns:TreePSet<E>

a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement

Annotations
@Override
higherback to summary
public E higher(final E e)

Implements java.util.NavigableSet.higher.

Doc from java.util.NavigableSet.higher.

Returns the least element in this set strictly greater than the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the least element greater than e, or null if there is no such element

Annotations
@Override
intersectback to summary
public TreePSet<E> intersect(Collection<? extends E> list)

Overrides default org.pcollections.PSortedSet.intersect.

Returns:TreePSet<E>

Doc from org.pcollections.PSet.intersect.

the equivalent of this.minusAll(this.minusAll(list)).

Annotations
@Override
iteratorback to summary
public Iterator<E> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator, java.util.Set.iterator, java.util.NavigableSet.iterator.

Doc from java.util.NavigableSet.iterator.

Returns an iterator over the elements in this set, in ascending order.

Returns:Iterator<E>

an iterator over the elements in this set, in ascending order

Annotations
@Override
lastback to summary
public E last()

Implements java.util.SortedSet.last.

Doc from java.util.SortedSet.last.

Returns the last (highest) element currently in this set.

Returns:E

the last (highest) element currently in this set

Annotations
@Override
lowerback to summary
public E lower(final E e)

Implements java.util.NavigableSet.lower.

Doc from java.util.NavigableSet.lower.

Returns the greatest element in this set strictly less than the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the greatest element less than e, or null if there is no such element

Annotations
@Override
minusback to summary
public TreePSet<E> minus(final Object e)

Implements org.pcollections.PSortedSet.minus.

Returns:TreePSet<E>

Doc from org.pcollections.PSortedSet.minus.

This set, except with e removed (if e is an element of this set).

Annotations
@Override
minusAllback to summary
public TreePSet<E> minusAll(final Collection<?> list)

Implements org.pcollections.PSortedSet.minusAll.

Returns:TreePSet<E>

Doc from org.pcollections.PSortedSet.minusAll.

This set, except with the elements of list removed (if they are elements of this set).

Annotations
@Override
minusFirstback to summary
public TreePSet<E> minusFirst()

Implements org.pcollections.PSortedSet.minusFirst.

Returns:TreePSet<E>

Doc from org.pcollections.PSortedSet.minusFirst.

This set, except with its first (least) element removed.

Annotations
@Override
minusLastback to summary
public TreePSet<E> minusLast()

Implements org.pcollections.PSortedSet.minusLast.

Returns:TreePSet<E>

Doc from org.pcollections.PSortedSet.minusLast.

This set, except with its last (greatest) element removed.

Annotations
@Override
ofback to summary
public static <E extends Comparable<? super E>> TreePSet<E> of(final E... elements)

Hides java.util.Set.of, java.util.Set.of.

Returns a TreePSet with the specified elements, using their natural ordering.

Parameters
<E>
the type of elements to be maintained by the set
elements:E[]

the elements to include; may include duplicates, but the returned TreePSet will not

Returns:TreePSet<E>

a TreePSet containing the specified elements and using their natural ordering

Annotations
@SafeVarargs
Exceptions
NullPointerException:
if any of the specified elements is null, or if the varargs array-ref is itself null
ofback to summary
public static <E> TreePSet<E> of(final Comparator<? super E> comparator, final E... elements)

Hides java.util.Set.of.

Returns a TreePSet with the specified comparator and elements.

Parameters
<E>
the type of elements to be maintained by the set
comparator:Comparator<? super E>

the comparator to use

elements:E[]

the elements to include; may include duplicates, but the returned TreePSet will not

Returns:TreePSet<E>

a TreePSet containing the specified elements and using the specified comparator

Annotations
@SafeVarargs
Exceptions
NullPointerException:
if the specified comparator is null, or if any of the specified elements is null, or if the varargs array-ref is itself null
plusback to summary
public TreePSet<E> plus(final E e)

Implements org.pcollections.PSortedSet.plus.

Returns:TreePSet<E>

Doc from org.pcollections.PSortedSet.plus.

This set, except with e added (unless e is already an element of this set).

Annotations
@Override
plusAllback to summary
public TreePSet<E> plusAll(final Collection<? extends E> list)

Implements org.pcollections.PSortedSet.plusAll.

Returns:TreePSet<E>

Doc from org.pcollections.PSortedSet.plusAll.

This set, except with the elements of list added (unless they are already elements of this set).

Annotations
@Override
searchback to summary
private E search(final E e, final KVTree.SearchType searchTypeIfLeftToRight, final KVTree.SearchType searchTypeIfRightToLeft)
singletonback to summary
public static <E extends Comparable<? super E>> TreePSet<E> singleton(final E e)

Returns a TreePSet with a single element, using the natural ordering.

Parameters
<E>
the type of elements to be maintained by the set
e:E

the element

Returns:TreePSet<E>

a TreePSet containing the specified element and using the natural ordering

Exceptions
NullPointerException:
if the specified element is null
singletonback to summary
public static <E> TreePSet<E> singleton(final Comparator<? super E> comparator, final E e)

Returns a TreePSet with a single element, using the specified comparator.

Parameters
<E>
the type of elements to be maintained by the set
comparator:Comparator<? super E>

the comparator according to which elements should be ordered

e:E

the element

Returns:TreePSet<E>

a TreePSet containing the specified element and using the specified comparator

Exceptions
NullPointerException:
if either the comparator or the element is null
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size, java.util.Set.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this set (its cardinality)

Annotations
@Override
sneakilyDowncastback to summary
private static <T> T sneakilyDowncast(final Object o)
Annotations
@SuppressWarnings:unchecked
subSetback to summary
public TreePSet<E> subSet(final E fromElement, final E toElement)

Implements org.pcollections.PSortedSet.subSet.

Doc from java.util.NavigableSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Equivalent to subSet(fromElement, true, toElement, false).

Parameters
fromElement:E

Doc from java.util.SortedSet.subSet.

low endpoint (inclusive) of the returned set

toElement:E

Doc from java.util.SortedSet.subSet.

high endpoint (exclusive) of the returned set

Returns:TreePSet<E>

Doc from java.util.SortedSet.subSet.

a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive

Annotations
@Override
subSetback to summary
public TreePSet<E> subSet(final E fromElement, final boolean fromInclusive, final E toElement, final boolean toInclusive)

Implements org.pcollections.PSortedSet.subSet.

Doc from java.util.NavigableSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement to toElement. If fromElement and toElement are equal, the returned set is empty unless fromInclusive and toInclusive are both true. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:E

low endpoint of the returned set

fromInclusive:boolean

true if the low endpoint is to be included in the returned view

toElement:E

high endpoint of the returned set

toInclusive:boolean

true if the high endpoint is to be included in the returned view

Returns:TreePSet<E>

a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive

Annotations
@Override
tailSetback to summary
public TreePSet<E> tailSet(final E fromElement)

Implements org.pcollections.PSortedSet.tailSet.

Doc from java.util.NavigableSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Equivalent to tailSet(fromElement, true).

Parameters
fromElement:E

Doc from java.util.SortedSet.tailSet.

low endpoint (inclusive) of the returned set

Returns:TreePSet<E>

Doc from java.util.SortedSet.tailSet.

a view of the portion of this set whose elements are greater than or equal to fromElement

Annotations
@Override
tailSetback to summary
public TreePSet<E> tailSet(final E fromElement, final boolean inclusive)

Implements org.pcollections.PSortedSet.tailSet.

Doc from java.util.NavigableSet.tailSet.

Returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:E

low endpoint of the returned set

inclusive:boolean

true if the low endpoint is to be included in the returned view

Returns:TreePSet<E>

a view of the portion of this set whose elements are greater than or equal to fromElement

Annotations
@Override
toTreePSetback to summary
public static <E extends Comparable<? super E>> Collector<E, ?, TreePSet<E>> toTreePSet()

Returns a collector that gathers a stream into a TreePSet with the elements of that stream, using their natural ordering.

Parameters
<E>
the type of elements to be maintained by the set
Returns:Collector<E, ?, TreePSet<E>>

a collector that gathers the elements of the stream into a TreePSet that uses the natural ordering

toTreePSetback to summary
public static <E> Collector<E, ?, TreePSet<E>> toTreePSet(final Comparator<? super E> comparator)

Returns a collector that gathers a stream into a TreePSet with the elements of that stream, using the specified comparator.

Parameters
<E>
the type of elements to be maintained by the set
comparator:Comparator<? super E>

the comparator to use

Returns:Collector<E, ?, TreePSet<E>>

a collector that gathers the elements of the stream into a TreePSet that uses the specified comparator

Exceptions
NullPointerException:
if the comparator is null
withTreeback to summary
private TreePSet<E> withTree(final KVTree<E, ?> tree)