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
ConstructorDescriptionUniqueIterator
(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, wait
Methods inherited from interface io.permazen.util.CloseableIterator
toStream
Methods 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
- ifiterator
is null
-
UniqueIterator
Constructor.A zero result from
comparator
is used to detect duplicates. Ifcomparator
is null,Object.equals(java.lang.Object)
is used.- Parameters:
iterator
- wrappedIterator
comparator
- used to compare consecutive values, or null to useObject.equals(java.lang.Object)
- Throws:
IllegalArgumentException
- ifiterator
is null
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceCloseableIterator<E>
-