E
- the type of content of this Setpublic abstract class ImmutableAbstractSet<E> extends Object implements ImmutableSet<E>
Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Modifier | Constructor and Description |
---|---|
protected |
ImmutableAbstractSet(Collection<E> collection,
boolean copy)
Construct an abstract immutable set.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Object o)
Returns true if this immutable collection contains the specified element.
|
boolean |
containsAll(Collection<?> c)
Returns true if this immutable collection contains all of the elements in the specified collection.
|
boolean |
containsAll(ImmutableCollection<?> c)
Returns true if this immutable collection contains all of the elements in the specified immutable collection.
|
boolean |
equals(Object obj)
Force to redefine equals for the implementations of immutable collection classes.
|
void |
forEach(Consumer<? super E> action) |
protected Collection<E> |
getSet()
Prepare the set of the right type for use a subclass.
|
int |
hashCode()
Force to redefine hashCode for the implementations of immutable collection classes.
|
boolean |
isEmpty()
Returns true if this immutable collection contains no elements.
|
boolean |
isWrap()
Return whether the internal storage is a wrapped pointer to the original collection.
|
ImmutableIterator<E> |
iterator()
Returns an immutable iterator over the elements in this immutable collection.
|
Stream<E> |
parallelStream()
Returns a possibly parallel
Stream with this collection as its source. |
int |
size()
Returns the number of elements in this immutable collection.
|
Spliterator<E> |
spliterator()
Creates a Spliterator over the elements in this collection.
|
Stream<E> |
stream()
Returns a sequential
Stream with this collection as its source. |
Object[] |
toArray()
Returns an array containing all of the elements in this immutable collection.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this immutable collection; the runtime type of the returned array is
that of the specified array.
|
Collection<E> |
toCollection()
Returns a modifiable copy of this immutable collection.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
toSet
isCopy
protected ImmutableAbstractSet(Collection<E> collection, boolean copy)
collection
- a safe copy of the collection to use as the immutable setcopy
- indicate whether the immutable is a copy or a wrapprotected Collection<E> getSet()
@Override protected ArraySet<E> getSet() { return (ArraySet<E>) super.getSet(); }
public final Collection<E> toCollection()
toCollection
in interface ImmutableCollection<E>
public final int size()
size
in interface ImmutableCollection<E>
public final boolean isEmpty()
isEmpty
in interface ImmutableCollection<E>
public final boolean contains(Object o)
contains
in interface ImmutableCollection<E>
o
- element whose presence in this immutable collection is to be testedpublic final Object[] toArray()
See java.util.Collection.toArray() for more details.
toArray
in interface ImmutableCollection<E>
public final <T> T[] toArray(T[] a)
See java.util.Collection.toArray(T[]) for more details.
toArray
in interface ImmutableCollection<E>
T
- the runtime type of the array to contain the immutable collectiona
- the array into which the elements of this immutable collection are to be stored, if it is big enough; otherwise,
a new array of the same runtime type is allocated for this purpose.public final ImmutableIterator<E> iterator()
public final Spliterator<E> spliterator()
spliterator
in interface Iterable<E>
spliterator
in interface ImmutableCollection<E>
Spliterator
over the elements in this collectionpublic final boolean containsAll(Collection<?> c)
containsAll
in interface ImmutableCollection<E>
c
- collection to be checked for containment in this immutable collectionImmutableCollection.contains(Object)
public final boolean containsAll(ImmutableCollection<?> c)
containsAll
in interface ImmutableCollection<E>
c
- immutable collection to be checked for containment in this immutable collectionImmutableCollection.contains(Object)
public final Stream<E> stream()
Stream
with this collection as its source.
This method should be overridden when the ImmutableCollection.spliterator()
method cannot return a spliterator that is
IMMUTABLE
, CONCURRENT
, or late-binding. (See ImmutableCollection.spliterator()
for details.)
stream
in interface ImmutableCollection<E>
Stream
over the elements in this collectionpublic final Stream<E> parallelStream()
Stream
with this collection as its source. It is allowable for this method to return
a sequential stream.
This method should be overridden when the ImmutableCollection.spliterator()
method cannot return a spliterator that is
IMMUTABLE
, CONCURRENT
, or late-binding. (See ImmutableCollection.spliterator()
for details.)
parallelStream
in interface ImmutableCollection<E>
Stream
over the elements in this collectionpublic final boolean isWrap()
isWrap
in interface ImmutableCollection<E>
public int hashCode()
hashCode
in interface ImmutableCollection<E>
hashCode
in interface ImmutableSet<E>
hashCode
in class Object
public boolean equals(Object obj)
equals
in interface ImmutableCollection<E>
equals
in interface ImmutableSet<E>
equals
in class Object
obj
- the object to compare this collection withCopyright © 2014–2016 Delft University of Technology. All rights reserved.