info.aduna.collections.iterators
Class MinusIterator<E>

java.lang.Object
  extended by info.aduna.iteration.CloseableIterationBase<E,X>
      extended by info.aduna.iteration.IterationWrapper<E,X>
          extended by info.aduna.iteration.FilterIteration<E,X>
              extended by info.aduna.iteration.MinusIteration<E,RuntimeException>
                  extended by info.aduna.collections.iterators.MinusIterator<E>
All Implemented Interfaces:
CloseableIterator<E>, CloseableIteration<E,RuntimeException>, Iteration<E,RuntimeException>, Closeable, Iterator<E>

public class MinusIterator<E>
extends MinusIteration<E,RuntimeException>
implements CloseableIterator<E>

An iterator that returns the results of an iterator (the left argument) minus the results of another iterator (the right argument). Optionally, the iterator can be configured to filter duplicates from the returned elements.

Note that duplicates can also be filtered by wrapping this iterator in a DistinctIterator, but that has a bit more overhead as it adds a second hash table lookup.


Field Summary
 
Fields inherited from class info.aduna.iteration.IterationWrapper
wrappedIter
 
Fields inherited from class info.aduna.iteration.CloseableIterationBase
logger
 
Constructor Summary
MinusIterator(Iterator<? extends E> leftArg, Iterator<? extends E> rightArg)
          Creates a new MinusIterator that returns the results of the left argument minus the results of the right argument.
MinusIterator(Iterator<? extends E> leftArg, Iterator<? extends E> rightArg, boolean distinct)
          Creates a new MinusIterator that returns the results of the left argument minus the results of the right argument.
 
Method Summary
 
Methods inherited from class info.aduna.iteration.MinusIteration
accept, handleClose
 
Methods inherited from class info.aduna.iteration.FilterIteration
hasNext, next
 
Methods inherited from class info.aduna.iteration.IterationWrapper
remove
 
Methods inherited from class info.aduna.iteration.CloseableIterationBase
close, isClosed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.aduna.collections.iterators.CloseableIterator
close
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

MinusIterator

public MinusIterator(Iterator<? extends E> leftArg,
                     Iterator<? extends E> rightArg)
Creates a new MinusIterator that returns the results of the left argument minus the results of the right argument. By default, duplicates are not filtered from the results.

Parameters:
leftArg - An iterator containing the main set of elements.
rightArg - An iterator containing the set of elements that should be filtered from the main set.

MinusIterator

public MinusIterator(Iterator<? extends E> leftArg,
                     Iterator<? extends E> rightArg,
                     boolean distinct)
Creates a new MinusIterator that returns the results of the left argument minus the results of the right argument.

Parameters:
leftArg - An iterator containing the main set of elements.
rightArg - An iterator containing the set of elements that should be filtered from the main set.
distinct - Flag indicating whether duplicate elements should be filtered from the result.


Copyright © 1997-2008 Aduna. All Rights Reserved.