E - the type of code list elements in the set.public class CodeListSet<E extends CodeList<E>> extends AbstractSet<E> implements CheckedContainer<E>, Cloneable, Serializable
Set implementation for use with CodeList values.
All elements in a CodeListSet are of the same CodeList class,
which must be final. Iterators traverse the elements in the order in which the
code list constants are declared.
CodeListSet is implemented internally by bit vectors for compact and efficient storage.
All bulk operations (addAll, removeAll, containsAll) are very quick if
their argument is also a CodeListSet instance.
AxisDirections
for a (x,y,z) coordinate system:
CodeListSet<AxisDirection> codes = new CodeListSet<>(AxisDirection.class); Collections.addAll(codes, AxisDirection.EAST, AxisDirection.NORTH, AxisDirection.UP),
EnumSet,
Serialized FormDefined in the sis-utility module
| Constructor and Description |
|---|
CodeListSet(Class<E> elementType)
Creates an initially empty set for code lists of the given type.
|
CodeListSet(Class<E> elementType,
boolean fill)
Creates set for code lists of the given type.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E element)
Adds the specified code list element in this set.
|
boolean |
addAll(Collection<? extends E> c)
Adds all elements of the given collection to this set.
|
void |
clear()
Removes all elements from this set.
|
CodeListSet<E> |
clone()
Returns a new set of the same class containing the same elements than this set.
|
boolean |
contains(Object object)
Returns
true if this set contains the given element. |
boolean |
containsAll(Collection<?> c)
Returns
true if this set contains all the elements of the given collection. |
Class<E> |
getElementType()
Returns the type of code list elements in this set.
|
boolean |
isEmpty()
Returns
true if this set does not contains any element. |
Iterator<E> |
iterator()
Returns an iterator over the elements in this set.
|
boolean |
remove(Object object)
Removes the specified code list element from this set.
|
boolean |
removeAll(Collection<?> c)
Adds all elements of the given collection from this set.
|
boolean |
retainAll(Collection<?> c)
Retains only the elements of the given collection in this set.
|
int |
size()
Returns the number of elements in this set.
|
equals, hashCodetoArray, toArray, toStringspliterator, toArray, toArrayparallelStream, removeIf, streampublic CodeListSet(Class<E> elementType) throws IllegalArgumentException
CodeList type shall be final.elementType - the type of code list elements to be included in this set.IllegalArgumentException - if the given class is not final.public CodeListSet(Class<E> elementType, boolean fill) throws IllegalArgumentException
fill argument is false,
then the new set will be initially empty. Otherwise the new set will be filled with all code
list elements of the given type that are known at construction time. Note that if new code
list elements are created after the invocation of this CodeListSet constructor, then
those new elements will not be in this set.elementType - the type of code list elements to be included in this set.fill - true for filling the set with all known elements of the given type,
or false for leaving the set empty.IllegalArgumentException - if the given class is not final.public Class<E> getElementType()
getElementType in interface CheckedContainer<E extends CodeList<E>>public void clear()
public boolean isEmpty()
true if this set does not contains any element.public int size()
public boolean add(E element)
add in interface Collection<E extends CodeList<E>>add in interface Set<E extends CodeList<E>>add in class AbstractCollection<E extends CodeList<E>>element - the code list element to add in this set.true if this set has been modified as a consequence of this method call.public boolean remove(Object object)
null or is
not an instance of the code list class specified at construction time.remove in interface Collection<E extends CodeList<E>>remove in interface Set<E extends CodeList<E>>remove in class AbstractCollection<E extends CodeList<E>>object - the code list element to remove from this set.true if this set has been modified as a consequence of this method call.public boolean contains(Object object)
true if this set contains the given element.
This methods returns false if the given argument is null or
is not an instance of the code list class specified at construction time.contains in interface Collection<E extends CodeList<E>>contains in interface Set<E extends CodeList<E>>contains in class AbstractCollection<E extends CodeList<E>>object - the element to test for presence in this set.true if the given object is contained in this set.public boolean containsAll(Collection<?> c)
true if this set contains all the elements of the given collection.containsAll in interface Collection<E extends CodeList<E>>containsAll in interface Set<E extends CodeList<E>>containsAll in class AbstractCollection<E extends CodeList<E>>c - the collection to be checked for containment in this set.true if this set contains all elements of the given collection.public boolean addAll(Collection<? extends E> c) throws IllegalArgumentException
addAll in interface Collection<E extends CodeList<E>>addAll in interface Set<E extends CodeList<E>>addAll in class AbstractCollection<E extends CodeList<E>>c - the collection containing elements to be added to this set.true if this set changed as a result of this method call.IllegalArgumentExceptionpublic boolean removeAll(Collection<?> c)
removeAll in interface Collection<E extends CodeList<E>>removeAll in interface Set<E extends CodeList<E>>removeAll in class AbstractSet<E extends CodeList<E>>c - the collection containing elements to be removed from this set.true if this set changed as a result of this method call.public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E extends CodeList<E>>retainAll in interface Set<E extends CodeList<E>>retainAll in class AbstractCollection<E extends CodeList<E>>c - the collection containing elements to retain in this set.true if this set changed as a result of this method call.public Iterator<E> iterator()
CodeListSet content at the time this method has been invoked. Changes in
this CodeListSet made after this method call will not affect the values
returned by the iterator.iterator in interface Iterable<E extends CodeList<E>>iterator in interface Collection<E extends CodeList<E>>iterator in interface Set<E extends CodeList<E>>iterator in class AbstractCollection<E extends CodeList<E>>public CodeListSet<E> clone()
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.