Class 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>

private static final class DerivedSet.Bijective<S,E> extends DerivedSet.Invertible<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 Details

    • serialVersionUID

      private static final long serialVersionUID
      For 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 interface Collection<S>
      Specified by:
      size in interface Set<S>
      Overrides:
      size in class SetOfUnknownSize<E>
      Returns:
      the number of elements in this set.
    • isEmpty

      public boolean isEmpty()
      Returns true if this set contains no elements.
      Specified by:
      isEmpty in interface Collection<S>
      Specified by:
      isEmpty in interface Set<S>
      Overrides:
      isEmpty in class DerivedSet<S,E>
      Returns:
      true if this set contains no elements.