info.aduna.collections.iterators
Class IntersectIterator<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.IntersectIteration<E,RuntimeException>
                  extended by info.aduna.collections.iterators.IntersectIterator<E>
All Implemented Interfaces:
CloseableIterator<E>, CloseableIteration<E,RuntimeException>, Iteration<E,RuntimeException>, Closeable, Iterator<E>

public class IntersectIterator<E>
extends IntersectIteration<E,RuntimeException>
implements CloseableIterator<E>

An iterator that returns the intersection of the results of two iterators. 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
IntersectIterator(Iterator<? extends E> arg1, Iterator<? extends E> arg2)
          Creates a new IntersectIterator that returns the intersection of the results of two iterators.
IntersectIterator(Iterator<? extends E> arg1, Iterator<? extends E> arg2, boolean distinct)
          Creates a new IntersectIterator that returns the intersection of the results of two iterators.
 
Method Summary
 
Methods inherited from class info.aduna.iteration.IntersectIteration
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

IntersectIterator

public IntersectIterator(Iterator<? extends E> arg1,
                         Iterator<? extends E> arg2)
Creates a new IntersectIterator that returns the intersection of the results of two iterators. By default, duplicates are not filtered from the results.

Parameters:
arg1 - An iterator containing the first set of elements.
arg2 - An iterator containing the second set of elements.

IntersectIterator

public IntersectIterator(Iterator<? extends E> arg1,
                         Iterator<? extends E> arg2,
                         boolean distinct)
Creates a new IntersectIterator that returns the intersection of the results of two iterators.

Parameters:
arg1 - An iterator containing the first set of elements.
arg2 - An iterator containing the second set of elements.
distinct - Flag indicating whether duplicate elements should be filtered from the result.


Copyright © 1997-2008 Aduna. All Rights Reserved.