Class NiceIterator<T>

    • Constructor Summary

      Constructors 
      Constructor Description
      NiceIterator()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> ExtendedIterator<T> andThen​(java.util.Iterator<T> a, java.util.Iterator<? extends T> b)
      concatenate two closable iterators.
      <X extends T>
      ExtendedIterator<T>
      andThen​(java.util.Iterator<X> other)
      make a new iterator, which is us then the other chap.
      static <T> java.util.List<T> asList​(ExtendedIterator<T> it)
      Answer a list of the elements from it, in order, consuming that iterator.
      static <T> java.util.Set<T> asSet​(ExtendedIterator<T> it)
      Answer a list of the elements of it in order, consuming this iterator.
      void close()
      default close: don't need to do anything.
      static void close​(java.util.Iterator<?> it)
      If it is Closeable, close it.
      static <T> ExtendedIterator<T> emptyIterator()
      An iterator over no elements.
      FilterIterator<T> filterDrop​(java.util.function.Predicate<T> f)
      make a new iterator, which is our elements that do not pass the filter
      FilterIterator<T> filterKeep​(java.util.function.Predicate<T> f)
      make a new iterator, which is our elements that pass the filter
      boolean hasNext()
      default hasNext: no elements, return false.
      <U> ExtendedIterator<U> mapWith​(java.util.function.Function<T,​U> map1)
      make a new iterator which is the elementwise _map1_ of the base iterator.
      T next()
      default next: throw an exception.
      void remove()
      default remove: we have no elements, so we can't remove any.
      T removeNext()
      Answer the next object, and remove it.
      java.util.List<T> toList()
      Answer a list of the elements in order, consuming this iterator.
      java.util.Set<T> toSet()
      Answer a list of the elements in order, consuming this iterator.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • NiceIterator

        public NiceIterator()
    • Method Detail

      • hasNext

        public boolean hasNext()
        default hasNext: no elements, return false.
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • next

        public T next()
        default next: throw an exception.
        Specified by:
        next in interface java.util.Iterator<T>
      • remove

        public void remove()
        default remove: we have no elements, so we can't remove any.
        Specified by:
        remove in interface java.util.Iterator<T>
      • andThen

        public static <T> ExtendedIterator<T> andThen​(java.util.Iterator<T> a,
                                                      java.util.Iterator<? extends T> b)
        concatenate two closable iterators.
      • filterDrop

        public FilterIterator<T> filterDrop​(java.util.function.Predicate<T> f)
        make a new iterator, which is our elements that do not pass the filter
        Specified by:
        filterDrop in interface ExtendedIterator<T>
      • mapWith

        public <U> ExtendedIterator<U> mapWith​(java.util.function.Function<T,​U> map1)
        make a new iterator which is the elementwise _map1_ of the base iterator.
        Specified by:
        mapWith in interface ExtendedIterator<T>
      • close

        public static void close​(java.util.Iterator<?> it)
        If it is Closeable, close it.
      • emptyIterator

        public static <T> ExtendedIterator<T> emptyIterator()
        An iterator over no elements.
        Returns:
        A class singleton which doesn't iterate.
      • toList

        public java.util.List<T> toList()
        Answer a list of the elements in order, consuming this iterator.
        Specified by:
        toList in interface ExtendedIterator<T>
      • toSet

        public java.util.Set<T> toSet()
        Answer a list of the elements in order, consuming this iterator.
        Specified by:
        toSet in interface ExtendedIterator<T>
      • asSet

        public static <T> java.util.Set<T> asSet​(ExtendedIterator<T> it)
        Answer a list of the elements of it in order, consuming this iterator. Canonical implementation of toSet().
      • asList

        public static <T> java.util.List<T> asList​(ExtendedIterator<T> it)
        Answer a list of the elements from it, in order, consuming that iterator. Canonical implementation of toList().