Package io.permazen.util
Class UniqueIterator<E>
java.lang.Object
io.permazen.util.UniqueIterator<E>
- All Implemented Interfaces:
CloseableIterator<E>,Closeable,AutoCloseable,Iterator<E>
CloseableIterator implementation that provides a read-only view of an inner Iterator
in which consecutive duplicate values are eliminated.-
Constructor Summary
ConstructorsConstructorDescriptionUniqueIterator(Iterator<? extends E> iterator) Constructor.UniqueIterator(Iterator<? extends E> iterator, Comparator<? super E> comparator) Constructor. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.permazen.util.CloseableIterator
toStreamMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
UniqueIterator
Constructor.Object equality using
Object.equals(java.lang.Object)is used to detect duplicates.- Parameters:
iterator- wrappedIterator- Throws:
IllegalArgumentException- ifiteratoris null
-
UniqueIterator
Constructor.A zero result from
comparatoris used to detect duplicates. Ifcomparatoris null,Object.equals(java.lang.Object)is used.- Parameters:
iterator- wrappedIteratorcomparator- used to compare consecutive values, or null to useObject.equals(java.lang.Object)- Throws:
IllegalArgumentException- ifiteratoris null
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableIterator<E>
-