Package org.apache.sis.util.collection
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.util.collection.DerivedSet
converter, storage
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.sis.util.collection.DerivedSet.Invertible
add, contains, remove
Methods inherited from class org.apache.sis.util.collection.DerivedSet
add, create, getElementType, iterator
Methods inherited from class org.apache.sis.internal.util.SetOfUnknownSize
equals, isSizeKnown, removeAll, spliterator, toArray, toArray
Methods inherited from class java.util.AbstractSet
hashCode
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, retainAll, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.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:
size
in interfaceCollection<S>
- Specified by:
size
in interfaceSet<S>
- Overrides:
size
in classSetOfUnknownSize<E>
- Returns:
- the number of elements in this set.
-
isEmpty
public boolean isEmpty()Returnstrue
if this set contains no elements.- Specified by:
isEmpty
in interfaceCollection<S>
- Specified by:
isEmpty
in interfaceSet<S>
- Overrides:
isEmpty
in classDerivedSet<S,
E> - Returns:
true
if this set contains no elements.
-