Class AbstractIterationSet<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
io.permazen.util.AbstractIterationSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
AbstractNavigableSet, ConvertedSet

public abstract class AbstractIterationSet<E> extends AbstractSet<E>
Support superclass for Set implementations based on database entries.

This class assumes the following:

  • The size of the set is not cached, i.e., it requires an actual enumeration of all of the set's elements; and
  • Iteration may utilize a resource that needs to be closed

As a result:

To be safe, try-with-resources should be used with iterator() and stream().

For a read-only implementation, subclasses should implement contains() and iterator().

For a mutable implementation, subclasses should also implement add(), remove(), and clear(), and make the iterator() mutable.