public class UnmodifiableSet<E> extends UnmodifiableCollection<E> implements java.util.Set<E>
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.
Constructor and Description |
---|
UnmodifiableSet(java.util.Set<E> s)
Creates a new unmodifiable set from another set.
|
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 UnmodifiableSet(java.util.Set<E> s)