Class DerivedSet.Bijective<S,E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.apache.sis.internal.util.SetOfUnknownSize<E>
org.apache.sis.util.collection.DerivedSet<S,E>
org.apache.sis.util.collection.DerivedSet.Invertible<S,E>
org.apache.sis.util.collection.DerivedSet.Bijective<S,E>
- Type Parameters:
S- the type of elements in the storage set.E- the type of elements in this set.
- All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Set<E>, CheckedContainer<E>
- Enclosing class:
DerivedSet<S,E>
A
DerivedSet for converters that are both invertible and bijective.
The bijection allows us to query the DerivedSet.storage set size directly
instead of iterating over all elements.- Since:
- 0.3
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longFor cross-version compatibility.Fields inherited from class DerivedSet
converter, storage -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class DerivedSet.Invertible
add, contains, removeMethods inherited from class DerivedSet
add, create, getElementType, iteratorMethods inherited from class SetOfUnknownSize
equals, isSizeKnown, removeAll, spliterator, toArray, toArrayMethods inherited from class AbstractSet
hashCodeMethods inherited from class AbstractCollection
addAll, clear, containsAll, retainAll, toStringMethods inherited from interface Collection
parallelStream, removeIf, streamMethods inherited from interface Set
addAll, clear, containsAll, retainAll
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
-
Constructor Details
-
Bijective
Bijective(Set<S> storage, ObjectConverter<S, E> converter) Creates a new derived set from the specified storage set.- Parameters:
storage- the set which actually store the elements.converter- the type of elements in this derived set.
-
-
Method Details
-
size
public int size()Returns the number of elements in this set. The default implementation counts the number of elements returned by the iterator. Subclasses are encouraged to cache this value if they know that the underlying storage is immutable.- Specified by:
sizein interfaceCollection<S>- Specified by:
sizein interfaceSet<S>- Overrides:
sizein classSetOfUnknownSize<E>- Returns:
- the number of elements in this set.
-
isEmpty
public boolean isEmpty()Returnstrueif this set contains no elements.- Specified by:
isEmptyin interfaceCollection<S>- Specified by:
isEmptyin interfaceSet<S>- Overrides:
isEmptyin classDerivedSet<S,E> - Returns:
trueif this set contains no elements.
-