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 Summary

      Constructors 
      Constructor Description
      LazySet​(Iterator<? extends E> iterator)
      Construct a set to be filled using the specified iterator.
      LazySet​(Stream<? extends E> stream)
      Construct a set to be filled using the specified iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      E get​(int index)
      Returns the element at the specified position in this set.
      boolean isEmpty()
      Tests if this set has no elements.
      Iterator<E> iterator()
      Returns an iterator over the elements contained in this set.
      int size()
      Returns the number of elements in this set.
      • Methods inherited from class AbstractSet

        equals, hashCode, removeAll
      • Methods inherited from class AbstractCollection

        add, addAll, clear, contains, containsAll, remove, retainAll, toArray, toArray, toString
      • Methods inherited from class Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface Iterable

        forEach
      • Methods inherited from interface Set

        add, addAll, clear, contains, containsAll, remove, retainAll, spliterator, toArray, toArray
    • Constructor Detail

      • 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 Detail

      • 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.