TUM CCSM Commons

edu.tum.cs.commons.collections
Class UnmodifiableSortedSet<E>

java.lang.Object
  extended by edu.tum.cs.commons.collections.UnmodifiableCollection<E>
      extended by edu.tum.cs.commons.collections.UnmodifiableSet<E>
          extended by edu.tum.cs.commons.collections.UnmodifiableSortedSet<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, java.util.SortedSet<E>

public class UnmodifiableSortedSet<E>
extends UnmodifiableSet<E>
implements java.util.SortedSet<E>

This is a wrapper for a 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.

Version:
$Revision: 26283 $
Author:
Benjamin Hummel, $Author: juergens $
See Also:
Serialized Form
Rating:
GREEN Hash: 4A8EA373582003F0CC4E466C009BEA02

Constructor Summary
UnmodifiableSortedSet(java.util.SortedSet<E> s)
          Creates a new unmodifiable sorted set from another sorted set.
 
Method Summary
 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)
          
 
Methods inherited from class edu.tum.cs.commons.collections.UnmodifiableCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

UnmodifiableSortedSet

public UnmodifiableSortedSet(java.util.SortedSet<E> s)
Creates a new unmodifiable sorted set from another sorted set. All modifications to the underlying set will directly be visible in this wrapper.

Method Detail

comparator

public java.util.Comparator<? super E> comparator()

Specified by:
comparator in interface java.util.SortedSet<E>

first

public E first()

Specified by:
first in interface java.util.SortedSet<E>

headSet

public UnmodifiableSortedSet<E> headSet(E toElement)

Specified by:
headSet in interface java.util.SortedSet<E>

last

public E last()

Specified by:
last in interface java.util.SortedSet<E>

subSet

public UnmodifiableSortedSet<E> subSet(E fromElement,
                                       E toElement)

Specified by:
subSet in interface java.util.SortedSet<E>

tailSet

public UnmodifiableSortedSet<E> tailSet(E fromElement)

Specified by:
tailSet in interface java.util.SortedSet<E>

TUM CCSM Commons

TUM CCSM Commons - 2.7