Package org.apache.sis.util.collection
Class CodeListSet<E extends CodeList<E>>
Object
AbstractCollection<E>
AbstractSet<E>
CodeListSet<E>
- Type Parameters:
- E- the type of code list elements in the set.
- All Implemented Interfaces:
- Serializable,- Cloneable,- Iterable<E>,- Collection<E>,- Set<E>,- CheckedContainer<E>
public class CodeListSet<E extends CodeList<E>>
extends AbstractSet<E>
implements CheckedContainer<E>, Cloneable, Serializable
A specialized 
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.
 Implementation note
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.
 Usage example
The following example creates a set ofAxisDirections
 for a (x,y,z) coordinate system:
 CodeListSet<AxisDirection> codes = new CodeListSet<>(AxisDirection.class); Collections.addAll(codes, AxisDirection.EAST, AxisDirection.NORTH, AxisDirection.UP),
- Since:
- 0.3
- See Also:
Defined in the sis-utility module
- 
Constructor SummaryConstructorsConstructorDescriptionCodeListSet(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.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanAdds the specified code list element in this set.booleanaddAll(Collection<? extends E> c) Adds all elements of the given collection to this set.voidclear()Removes all elements from this set.clone()Returns a new set of the same class containing the same elements than this set.booleanReturnstrueif this set contains the given element.booleancontainsAll(Collection<?> c) Returnstrueif this set contains all the elements of the given collection.Returns the type of code list elements in this set.booleanisEmpty()Returnstrueif this set does not contains any element.iterator()Returns an iterator over the elements in this set.booleanRemoves the specified code list element from this set.booleanremoveAll(Collection<?> c) Adds all elements of the given collection from this set.booleanretainAll(Collection<?> c) Retains only the elements of the given collection in this set.intsize()Returns the number of elements in this set.Methods inherited from class AbstractSetequals, hashCodeMethods inherited from class AbstractCollectiontoArray, toArray, toStringMethods inherited from interface CollectionparallelStream, removeIf, stream, toArrayMethods inherited from interface Setspliterator, toArray, toArray
- 
Constructor Details- 
CodeListSetCreates an initially empty set for code lists of the given type. The givenCodeListtype shall be final.- Parameters:
- elementType- the type of code list elements to be included in this set.
- Throws:
- IllegalArgumentException- if the given class is not final.
 
- 
CodeListSetCreates set for code lists of the given type. If thefillargument isfalse, 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 thisCodeListSetconstructor, then those new elements will not be in this set.- Parameters:
- elementType- the type of code list elements to be included in this set.
- fill-- truefor filling the set with all known elements of the given type, or- falsefor leaving the set empty.
- Throws:
- IllegalArgumentException- if the given class is not final.
 
 
- 
- 
Method Details- 
getElementTypeReturns the type of code list elements in this set.- Specified by:
- getElementTypein interface- CheckedContainer<E extends CodeList<E>>
- Returns:
- the type of code list elements in this set.
 
- 
clearpublic void clear()Removes all elements from this set.
- 
isEmptypublic boolean isEmpty()Returnstrueif this set does not contains any element.
- 
sizepublic int size()Returns the number of elements in this set.
- 
addAdds the specified code list element in this set.- Specified by:
- addin interface- Collection<E extends CodeList<E>>
- Specified by:
- addin interface- Set<E extends CodeList<E>>
- Overrides:
- addin class- AbstractCollection<E extends CodeList<E>>
- Parameters:
- element- the code list element to add in this set.
- Returns:
- trueif this set has been modified as a consequence of this method call.
 
- 
removeRemoves the specified code list element from this set. This methods does nothing if the given argument isnullor is not an instance of the code list class specified at construction time.- Specified by:
- removein interface- Collection<E extends CodeList<E>>
- Specified by:
- removein interface- Set<E extends CodeList<E>>
- Overrides:
- removein class- AbstractCollection<E extends CodeList<E>>
- Parameters:
- object- the code list element to remove from this set.
- Returns:
- trueif this set has been modified as a consequence of this method call.
 
- 
containsReturnstrueif this set contains the given element. This methods returnsfalseif the given argument isnullor is not an instance of the code list class specified at construction time.- Specified by:
- containsin interface- Collection<E extends CodeList<E>>
- Specified by:
- containsin interface- Set<E extends CodeList<E>>
- Overrides:
- containsin class- AbstractCollection<E extends CodeList<E>>
- Parameters:
- object- the element to test for presence in this set.
- Returns:
- trueif the given object is contained in this set.
 
- 
containsAllReturnstrueif this set contains all the elements of the given collection.- Specified by:
- containsAllin interface- Collection<E extends CodeList<E>>
- Specified by:
- containsAllin interface- Set<E extends CodeList<E>>
- Overrides:
- containsAllin class- AbstractCollection<E extends CodeList<E>>
- Parameters:
- c- the collection to be checked for containment in this set.
- Returns:
- trueif this set contains all elements of the given collection.
 
- 
addAllAdds all elements of the given collection to this set.- Specified by:
- addAllin interface- Collection<E extends CodeList<E>>
- Specified by:
- addAllin interface- Set<E extends CodeList<E>>
- Overrides:
- addAllin class- AbstractCollection<E extends CodeList<E>>
- Parameters:
- c- the collection containing elements to be added to this set.
- Returns:
- trueif this set changed as a result of this method call.
- Throws:
- IllegalArgumentException
 
- 
removeAllAdds all elements of the given collection from this set.- Specified by:
- removeAllin interface- Collection<E extends CodeList<E>>
- Specified by:
- removeAllin interface- Set<E extends CodeList<E>>
- Overrides:
- removeAllin class- AbstractSet<E extends CodeList<E>>
- Parameters:
- c- the collection containing elements to be removed from this set.
- Returns:
- trueif this set changed as a result of this method call.
 
- 
retainAllRetains only the elements of the given collection in this set.- Specified by:
- retainAllin interface- Collection<E extends CodeList<E>>
- Specified by:
- retainAllin interface- Set<E extends CodeList<E>>
- Overrides:
- retainAllin class- AbstractCollection<E extends CodeList<E>>
- Parameters:
- c- the collection containing elements to retain in this set.
- Returns:
- trueif this set changed as a result of this method call.
 
- 
iteratorReturns an iterator over the elements in this set. The instance returned by this implementation will iterate over a snapshot of thisCodeListSetcontent at the time this method has been invoked. Changes in thisCodeListSetmade after this method call will not affect the values returned by the iterator.- Specified by:
- iteratorin interface- Collection<E extends CodeList<E>>
- Specified by:
- iteratorin interface- Iterable<E extends CodeList<E>>
- Specified by:
- iteratorin interface- Set<E extends CodeList<E>>
- Specified by:
- iteratorin class- AbstractCollection<E extends CodeList<E>>
- Returns:
- an iterator over the elements in this set.
 
- 
cloneReturns a new set of the same class containing the same elements than this set.
 
-