public class ConsistentSet<T> extends AbstractSet<T> implements Serializable
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.
Constructor and Description |
---|
ConsistentSet()
Constructs a new, empty
ConsistentSet . |
ConsistentSet(AtomicSerial.GetArg arg) |
ConsistentSet(Collection<T> init)
Constructs a new
ConsistentSet containing the elements
in the passed collection. |
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
elements(Collection<T> init) |
Iterator<T> |
iterator()
Returns an
iterator over the elements in this set. |
int |
size()
Returns the number of elements in this
ConsistentSet (its cardinality). |
equals, hashCode, removeAll
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public ConsistentSet()
ConsistentSet
. All instances
of ConsistentSet
are unmodifiable.public ConsistentSet(Collection<T> init)
ConsistentSet
containing the elements
in the passed collection. All instances of ConsistentSet
are unmodifiable.init
- the collection whose elements are to be placed into this set.NullPointerException
- if the passed init
reference
is null
public ConsistentSet(AtomicSerial.GetArg arg) throws IOException
IOException
public static <T> T[] elements(Collection<T> init)
public Iterator<T> iterator()
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
.public int size()
ConsistentSet
(its cardinality).size
in interface Collection<T>
size
in interface Set<T>
size
in class AbstractCollection<T>
ConsistentSet
(its cardinality).Copyright © 2016–2018. All rights reserved.