Class LazySet<E>

All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public final class LazySet<E> extends AbstractSet<E>
An immutable set built from an iterator, which will be filled only when needed. This implementation do not check if all elements in the iterator are really unique; we assume that it was already verified by ServiceRegistry. This set is constructed by org.geotools.referencing.FactoryFinder.
Since:
2.0
Author:
Martin Desruisseaux (IRD)
  • Constructor Details

    • LazySet

      public LazySet(Iterator<? extends E> iterator)
      Construct a set to be filled using the specified iterator. Iteration in the given iterator will occurs only when needed.
    • LazySet

      public LazySet(Stream<? extends E> stream)
      Construct a set to be filled using the specified iterator. Iteration in the given iterator will occurs only when needed.
  • Method Details

    • iterator

      public Iterator<E> iterator()
      Returns an iterator over the elements contained in this set. This is not the same iterator than the one given to the constructor.
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface Set<E>
      Specified by:
      iterator in class AbstractCollection<E>
    • size

      public int size()
      Returns the number of elements in this set. Invoking this method force the set to immediately iterates through all remaining elements.
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface Set<E>
      Specified by:
      size in class AbstractCollection<E>
    • isEmpty

      public boolean isEmpty()
      Tests if this set has no elements.
      Specified by:
      isEmpty in interface Collection<E>
      Specified by:
      isEmpty in interface Set<E>
      Overrides:
      isEmpty in class AbstractCollection<E>
    • get

      public E get(int index)
      Returns the element at the specified position in this set.