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

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

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