com.artima.lookup.util
Class ConsistentSet
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractSet
|
+--com.artima.lookup.util.ConsistentSet
- All Implemented Interfaces:
- java.util.Collection, java.io.Serializable, java.util.Set
- public class ConsistentSet
- extends java.util.AbstractSet
- implements java.io.Serializable
An implementation of the java.util.Set interface that has
a serialized form consistent in all virtual machines. ConsistentSet
instances are unmodifiable. All mutator methods, such as add and
remove, throw UnsupportedOperationException.
This class permits the null element.
Although instances of this class are unmodifiable, they are not necessarily
immutable. If a client retrieves a mutable object contained in a
ConsistentSet and mutates that object, the client in effect
mutates the state of the ConsistentSet. In this case, the
serialized form of the ConsistentSet will also most likely
have been mutated. A ConsistentSet that contains only immutable
objects will maintain a consistent serialized form indefinitely. But a
ConsistentSet that contains mutable objects will maintain a
consistent serialized form only so long as the mutable objects are not
mutated.
- See Also:
- Serialized Form
|
Constructor Summary |
ConsistentSet()
Constructs a new, empty ConsistentSet. |
ConsistentSet(java.util.Collection init)
Constructs a new ConsistentSet containing the elements
in the passed collection. |
|
Method Summary |
java.util.Iterator |
iterator()
Returns an iterator over the elements in this set. |
int |
size()
Returns the number of elements in this ConsistentSet (its cardinality). |
| Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray |
ConsistentSet
public ConsistentSet()
- Constructs a new, empty
ConsistentSet. All instances
of ConsistentSet are unmodifiable.
ConsistentSet
public ConsistentSet(java.util.Collection init)
- Constructs a new
ConsistentSet containing the elements
in the passed collection. All instances of ConsistentSet
are unmodifiable.
- Parameters:
init - the collection whose elements are to be placed into this set.
iterator
public java.util.Iterator iterator()
- Returns an
iterator over the elements in this set. The elements
are returned in no particular order. Because all instances of
ConsistentSet are unmodifiable, the remove method
of the returned Iterator throws
UnsupportedOperationException.
- Overrides:
iterator in class java.util.AbstractCollection
- Returns:
- an
Iterator over the elements in this
ConsistentSet.
size
public int size()
- Returns the number of elements in this
ConsistentSet (its cardinality).
- Overrides:
size in class java.util.AbstractCollection
- Returns:
- the number of elements in this
ConsistentSet (its cardinality).