public class UnmodifiableSortedSet<E> extends UnmodifiableSet<E> implements java.util.SortedSet<E>
SortedSet
prohibiting all calls which would
modify its contents. As the construction of this class is performed in
constant time it is prefered over copying the set (which takes linear time).
Using this class is also preferred to using the unmodifiableX()
in class Collections
as they return the collection base type that
does not signal, that the object ist unmodifiable. Using the classes in this
package makes unmodifiability more explicit.
All prohibited methods throw an UnsupportedOperationException
. The
class is nearly the same as the one returned by
Collections.unmodifiableSortedSet(java.util.SortedSet)
, but by making
it a public class we can make the return value of some methods more explicit.
Constructor and Description |
---|
UnmodifiableSortedSet(java.util.SortedSet<E> s)
Creates a new unmodifiable sorted set from another sorted set.
|
Modifier and Type | Method and Description |
---|---|
java.util.Comparator<? super E> |
comparator() |
E |
first() |
UnmodifiableSortedSet<E> |
headSet(E toElement) |
E |
last() |
UnmodifiableSortedSet<E> |
subSet(E fromElement,
E toElement) |
UnmodifiableSortedSet<E> |
tailSet(E fromElement) |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public UnmodifiableSortedSet(java.util.SortedSet<E> s)
public java.util.Comparator<? super E> comparator()
comparator
in interface java.util.SortedSet<E>
public UnmodifiableSortedSet<E> headSet(E toElement)
headSet
in interface java.util.SortedSet<E>
public UnmodifiableSortedSet<E> subSet(E fromElement, E toElement)
subSet
in interface java.util.SortedSet<E>
public UnmodifiableSortedSet<E> tailSet(E fromElement)
tailSet
in interface java.util.SortedSet<E>