TUM CCSM Commons

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

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

public class UnmodifiableSet<E>
extends UnmodifiableCollection<E>
implements java.util.Set<E>

This is a wrapper for a Set 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.unmodifiableSet(java.util.Set), 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: 1221FC9A0B5282EB5A1323A35B955157

Constructor Summary
UnmodifiableSet(java.util.Set<E> s)
          Creates a new unmodifiable set from another set.
 
Method Summary
 
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

UnmodifiableSet

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


TUM CCSM Commons

TUM CCSM Commons - 2.7