Top Description Fields Constructors Methods
org.apache.commons.collections4.set

public Class TransformedNavigableSet<E>

extends TransformedSortedSet<E>
implements NavigableSet<E>
Class Inheritance
All Implemented Interfaces
java.util.NavigableSet, java.util.SortedSet, java.util.SequencedSet, java.util.Set, java.util.Collection, java.lang.Iterable, java.util.SequencedCollection
Type Parameters
<E>
the type of the elements in this set
Imports
java.util.Iterator, .NavigableSet, org.apache.commons.collections4.Transformer

Decorates another NavigableSet to transform objects that are added.

The add methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.

Since
4.1

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
TransformedNavigableSet(final NavigableSet<E>
the set to decorate, must not be null
set
,
final Transformer<? super E, ? extends E>
the transformer to use for conversion, must not be null
transformer
)

Constructor that wraps (not copies).

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.
protected NavigableSet<E>

Returns:

the decorated navigable set
decorated
()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.decorated.

Gets the decorated navigable set.
public Iterator<E>
descendingIterator()

Implements java.util.NavigableSet.descendingIterator.

Returns an iterator over the elements in this set, in descending order.
public NavigableSet<E>
descendingSet()

Implements java.util.NavigableSet.descendingSet.

Returns a reverse order view of the elements contained 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 NavigableSet<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 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.
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 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 E
pollFirst()

Implements java.util.NavigableSet.pollFirst.

Retrieves and removes the first (lowest) element, or returns null if this set is empty.
public E
pollLast()

Implements java.util.NavigableSet.pollLast.

Retrieves and removes the last (highest) element, or returns null if this set is empty.
public NavigableSet<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 java.util.NavigableSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement to toElement.
public NavigableSet<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 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.
public static <
the element type
E
>
TransformedNavigableSet<E>

Returns:

a new transformed NavigableSet
transformedNavigableSet
(final NavigableSet<E>
the set to decorate, must not be null
set
,
final Transformer<? super E, ? extends E>
the transformer to use for conversion, must not be null
transformer
)

Factory method to create a transforming navigable set that will transform existing contents of the specified navigable set.

public static <
the element type
E
>
TransformedNavigableSet<E>

Returns:

a new transformed NavigableSet
transformingNavigableSet
(final NavigableSet<E>
the set to decorate, must not be null
set
,
final Transformer<? super E, ? extends E>
the transformer to use for conversion, must not be null
transformer
)

Factory method to create a transforming navigable set.

Inherited from org.apache.commons.collections4.set.TransformedSortedSet:
comparatorfirstgetSortedSetheadSetlastsubSettailSettransformedSortedSettransformingSortedSet

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.set.TransformedSortedSet.serialVersionUID.

Serialization version

Constructor Detail

TransformedNavigableSetback to summary
protected TransformedNavigableSet(final NavigableSet<E> set, final Transformer<? super E, ? extends E> transformer)

Constructor that wraps (not copies).

If there are any elements already in the set being decorated, they are NOT transformed.

Parameters
set:NavigableSet<E>

the set to decorate, must not be null

transformer:Transformer<? super E, ? extends E>

the transformer to use for conversion, must not be null

Exceptions
NullPointerException:
if set or transformer is null

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
decoratedback to summary
protected NavigableSet<E> decorated()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.decorated.

Gets the decorated navigable set.

Returns:NavigableSet<E>

the decorated navigable set

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 NavigableSet<E> descendingSet()

Implements java.util.NavigableSet.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:NavigableSet<E>

a reverse order view of 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
headSetback to summary
public NavigableSet<E> headSet(final E toElement, final boolean inclusive)

Implements java.util.NavigableSet.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:NavigableSet<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
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
pollFirstback to summary
public E pollFirst()

Implements java.util.NavigableSet.pollFirst.

Doc from java.util.NavigableSet.pollFirst.

Retrieves and removes the first (lowest) element, or returns null if this set is empty.

Returns:E

the first element, or null if this set is empty

Annotations
@Override
pollLastback to summary
public E pollLast()

Implements java.util.NavigableSet.pollLast.

Doc from java.util.NavigableSet.pollLast.

Retrieves and removes the last (highest) element, or returns null if this set is empty.

Returns:E

the last element, or null if this set is empty

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

Implements java.util.NavigableSet.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:NavigableSet<E>

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

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

Implements java.util.NavigableSet.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:NavigableSet<E>

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

Annotations
@Override
transformedNavigableSetback to summary
public static <E> TransformedNavigableSet<E> transformedNavigableSet(final NavigableSet<E> set, final Transformer<? super E, ? extends E> transformer)

Factory method to create a transforming navigable set that will transform existing contents of the specified navigable set.

If there are any elements already in the set being decorated, they will be transformed by this method. Contrast this with transformingNavigableSet(NavigableSet, Transformer).

Parameters
<E>
the element type
set:NavigableSet<E>

the set to decorate, must not be null

transformer:Transformer<? super E, ? extends E>

the transformer to use for conversion, must not be null

Returns:TransformedNavigableSet<E>

a new transformed NavigableSet

Exceptions
NullPointerException:
if set or transformer is null
transformingNavigableSetback to summary
public static <E> TransformedNavigableSet<E> transformingNavigableSet(final NavigableSet<E> set, final Transformer<? super E, ? extends E> transformer)

Factory method to create a transforming navigable set.

If there are any elements already in the set being decorated, they are NOT transformed. Contrast this with transformedNavigableSet(NavigableSet, Transformer).

Parameters
<E>
the element type
set:NavigableSet<E>

the set to decorate, must not be null

transformer:Transformer<? super E, ? extends E>

the transformer to use for conversion, must not be null

Returns:TransformedNavigableSet<E>

a new transformed NavigableSet

Exceptions
NullPointerException:
if set or transformer is null