Package org.djutils.immutablecollections
Class ImmutableTreeSet<E>
java.lang.Object
org.djutils.immutablecollections.ImmutableAbstractCollection<E>
org.djutils.immutablecollections.ImmutableAbstractSet<E>
org.djutils.immutablecollections.ImmutableTreeSet<E>
- Type Parameters:
E- the type of content of this Set
- All Implemented Interfaces:
Serializable,Iterable<E>,ImmutableCollection<E>,ImmutableNavigableSet<E>,ImmutableSet<E>,ImmutableSortedSet<E>
public class ImmutableTreeSet<E>
extends ImmutableAbstractSet<E>
implements ImmutableNavigableSet<E>
An immutable wrapper for a TreeSet.
Copyright (c) 2016-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
-
Field Summary
Fields inherited from class org.djutils.immutablecollections.ImmutableAbstractCollection
copyOrWrap -
Constructor Summary
ConstructorsConstructorDescriptionImmutableTreeSet(Collection<? extends E> sortedSet) ImmutableTreeSet(NavigableSet<E> treeSet, Immutable copyOrWrap) ImmutableTreeSet(ImmutableAbstractSet<E> immutableSortedSet) ImmutableTreeSet(ImmutableTreeSet<E> immutableTreeSet, Immutable copyOrWrap) -
Method Summary
Modifier and TypeMethodDescriptionfinal EReturns the least element in this immutable set greater than or equal to the given element, ornullif there is no such element.final Comparator<? super E>Returns the comparator used to order the elements in this immutable set, ornullif this immutable set uses the natural ordering of its elements.final ImmutableIterator<E>Returns an immutable iterator over the elements in this immutable set, in descending order.final ImmutableNavigableSet<E>Returns a reverse order view of the elements contained in this immutable set.final Efirst()Returns the first (lowest) element currently in this immutable set.final EReturns the greatest element in this immutable set less than or equal to the given element, ornullif there is no such element.protected NavigableSet<E>Returns the underlying collection of this immutable collection.final ImmutableSortedSet<E>Returns a view of the portion of this immutable set whose elements are strictly less thantoElement.final ImmutableNavigableSet<E>Returns a view of the portion of this immutable set whose elements are less than (or equal to, ifinclusiveis true)toElement.final EReturns the least element in this immutable set strictly greater than the given element, ornullif there is no such element.final Elast()Returns the last (highest) element currently in this immutable set.final EReturns the greatest element in this immutable set strictly less than the given element, ornullif there is no such element.final ImmutableNavigableSet<E>Returns a view of the portion of this immutable set whose elements range fromfromElementtotoElement.final ImmutableSortedSet<E>Returns a view of the portion of this immutable set whose elements range fromfromElement, inclusive, totoElement, exclusive.final ImmutableSortedSet<E>Returns a view of the portion of this immutable set whose elements are greater than or equal tofromElement.final ImmutableNavigableSet<E>Returns a view of the portion of this immutable set whose elements are greater than (or equal to, ifinclusiveis true)fromElement.final NavigableSet<E>toSet()Returns a modifiable copy of this immutable set.final StringtoString()Force to redefine toString.Methods inherited from class org.djutils.immutablecollections.ImmutableAbstractSet
contains, containsAll, containsAll, equals, forEach, hashCode, isEmpty, isWrap, iterator, parallelStream, size, spliterator, stream, toArray, toArray, toCollectionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.immutablecollections.ImmutableCollection
contains, containsAll, containsAll, isCopy, isEmpty, isWrap, iterator, parallelStream, size, spliterator, stream, toArray, toArray, toCollectionMethods inherited from interface org.djutils.immutablecollections.ImmutableNavigableSet
equals, hashCode
-
Constructor Details
-
ImmutableTreeSet
- Parameters:
sortedSet- the collection to use for the immutable set.
-
ImmutableTreeSet
- Parameters:
immutableSortedSet- the collection to use for the immutable set.
-
ImmutableTreeSet
- Parameters:
immutableTreeSet- the collection to use for the immutable set.copyOrWrap- WRAP stores a pointer to the original collection
-
-
Method Details
-
toSet
Description copied from interface:ImmutableNavigableSetReturns a modifiable copy of this immutable set.- Specified by:
toSetin interfaceImmutableNavigableSet<E>- Specified by:
toSetin interfaceImmutableSet<E>- Specified by:
toSetin interfaceImmutableSortedSet<E>- Returns:
- a modifiable copy of this immutable set.
-
getUnderlyingCollection
Description copied from class:ImmutableAbstractCollectionReturns the underlying collection of this immutable collection. In case of Immutable.WRAP, this will be the original collection. In case of IMMUTABLE.COPY, this will be the internally stored (mutable) copy of the collection.- Overrides:
getUnderlyingCollectionin classImmutableAbstractSet<E>- Returns:
- the underlying collection of this immutable collection.
-
comparator
Description copied from interface:ImmutableSortedSetReturns the comparator used to order the elements in this immutable set, ornullif this immutable set uses the natural ordering of its elements.- Specified by:
comparatorin interfaceImmutableSortedSet<E>- Returns:
- the comparator used to order the elements in this immutable set, or
nullif this immutable set uses the natural ordering of its elements
-
subSet
Description copied from interface:ImmutableSortedSetReturns a view of the portion of this immutable set whose elements range fromfromElement, inclusive, totoElement, exclusive. (IffromElementandtoElementare equal, the returned immutable set is empty.)The result of this method is a new, immutable sorted set.
- Specified by:
subSetin interfaceImmutableSortedSet<E>- Parameters:
fromElement- low endpoint (inclusive) of the returned immutable settoElement- high endpoint (exclusive) of the returned immutable set- Returns:
- a new, immutable sorted set of the portion of this immutable set whose elements range from
fromElement, inclusive, totoElement, exclusive
-
headSet
Description copied from interface:ImmutableSortedSetReturns a view of the portion of this immutable set whose elements are strictly less thantoElement. The returned immutable set is backed by this immutable set, so changes in the returned immutable set are reflected in this immutable set, and vice-versa. The returned immutable set supports all optional immutable set operations that this immutable set supports.The result of this method is a new, immutable sorted set.
- Specified by:
headSetin interfaceImmutableSortedSet<E>- Parameters:
toElement- high endpoint (exclusive) of the returned immutable set- Returns:
- a view of the portion of this immutable set whose elements are strictly less than
toElement
-
tailSet
Description copied from interface:ImmutableSortedSetReturns a view of the portion of this immutable set whose elements are greater than or equal tofromElement. The returned immutable set is backed by this immutable set, so changes in the returned immutable set are reflected in this immutable set, and vice-versa. The returned immutable set supports all optional immutable set operations that this immutable set supports.The result of this method is a new, immutable sorted set.
- Specified by:
tailSetin interfaceImmutableSortedSet<E>- Parameters:
fromElement- low endpoint (inclusive) of the returned immutable set- Returns:
- a view of the portion of this immutable set whose elements are greater than or equal to
fromElement
-
first
Description copied from interface:ImmutableSortedSetReturns the first (lowest) element currently in this immutable set.- Specified by:
firstin interfaceImmutableSortedSet<E>- Returns:
- the first (lowest) element currently in this immutable set
-
last
Description copied from interface:ImmutableSortedSetReturns the last (highest) element currently in this immutable set.- Specified by:
lastin interfaceImmutableSortedSet<E>- Returns:
- the last (highest) element currently in this immutable set
-
lower
Description copied from interface:ImmutableNavigableSetReturns the greatest element in this immutable set strictly less than the given element, ornullif there is no such element.- Specified by:
lowerin interfaceImmutableNavigableSet<E>- Parameters:
e- the value to match- Returns:
- the greatest element less than
e, ornullif there is no such element
-
floor
Description copied from interface:ImmutableNavigableSetReturns the greatest element in this immutable set less than or equal to the given element, ornullif there is no such element.- Specified by:
floorin interfaceImmutableNavigableSet<E>- Parameters:
e- the value to match- Returns:
- the greatest element less than or equal to
e, ornullif there is no such element
-
ceiling
Description copied from interface:ImmutableNavigableSetReturns the least element in this immutable set greater than or equal to the given element, ornullif there is no such element.- Specified by:
ceilingin interfaceImmutableNavigableSet<E>- Parameters:
e- the value to match- Returns:
- the least element greater than or equal to
e, ornullif there is no such element
-
higher
Description copied from interface:ImmutableNavigableSetReturns the least element in this immutable set strictly greater than the given element, ornullif there is no such element.- Specified by:
higherin interfaceImmutableNavigableSet<E>- Parameters:
e- the value to match- Returns:
- the least element greater than
e, ornullif there is no such element
-
descendingSet
Description copied from interface:ImmutableNavigableSetReturns a reverse order view of the elements contained in this immutable set.The returned immutable set has an ordering equivalent to
. The expressionCollections.reverseOrder(comparator())s.descendingSet().descendingSet()returns a view ofsessentially equivalent tos.- Specified by:
descendingSetin interfaceImmutableNavigableSet<E>- Returns:
- a reverse order view of this immutable set
-
descendingIterator
Description copied from interface:ImmutableNavigableSetReturns an immutable iterator over the elements in this immutable set, in descending order. Equivalent in effect todescendingSet().iterator().- Specified by:
descendingIteratorin interfaceImmutableNavigableSet<E>- Returns:
- an immutable iterator over the elements in this immutable set, in descending order
-
subSet
public final ImmutableNavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) Description copied from interface:ImmutableNavigableSetReturns a view of the portion of this immutable set whose elements range fromfromElementtotoElement. IffromElementandtoElementare equal, the returned immutable set is empty unlessfromInclusiveandtoInclusiveare both true.- Specified by:
subSetin interfaceImmutableNavigableSet<E>- Parameters:
fromElement- low endpoint of the returned immutable setfromInclusive-trueif the low endpoint is to be included in the returned viewtoElement- high endpoint of the returned immutable settoInclusive-trueif the high endpoint is to be included in the returned view- Returns:
- a view of the portion of this immutable set whose elements range from
fromElement, inclusive, totoElement, exclusive
-
headSet
Description copied from interface:ImmutableNavigableSetReturns a view of the portion of this immutable set whose elements are less than (or equal to, ifinclusiveis true)toElement.- Specified by:
headSetin interfaceImmutableNavigableSet<E>- Parameters:
toElement- high endpoint of the returned immutable setinclusive-trueif the high endpoint is to be included in the returned view- Returns:
- a view of the portion of this immutable set whose elements are less than (or equal to, if
inclusiveis true)toElement
-
tailSet
Description copied from interface:ImmutableNavigableSetReturns a view of the portion of this immutable set whose elements are greater than (or equal to, ifinclusiveis true)fromElement.- Specified by:
tailSetin interfaceImmutableNavigableSet<E>- Parameters:
fromElement- low endpoint of the returned immutable setinclusive-trueif the low endpoint is to be included in the returned view- Returns:
- a view of the portion of this immutable set whose elements are greater than or equal to
fromElement
-
toString
Description copied from interface:ImmutableSetForce to redefine toString.- Specified by:
toStringin interfaceImmutableSet<E>- Overrides:
toStringin classObject- Returns:
- a description of this immutable set
-