Class Sorted<T>

  • Type Parameters:
    T - Element type
    All Implemented Interfaces:
    Iterator<T>

    public final class Sorted<T>
    extends Object
    implements Iterator<T>
    Sorted iterator.

    There is no thread-safety guarantee.

    Since:
    0.7
    • Constructor Detail

      • Sorted

        public Sorted​(Iterator<? extends T> items)
        Ctor.

        If you're using this ctor you must be sure that type T implements Comparable interface. Otherwise, there will be a type casting exception in runtime.

        Parameters:
        items - The underlying iterator
      • Sorted

        public Sorted​(Comparator<? super T> comparator,
                      Iterator<? extends T> iterator)
        Ctor.
        Parameters:
        comparator - The comparator
        iterator - The underlying iterator
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface Iterator<T>