com.hp.hpl.jena.util.iterator
Class UniqueExtendedIterator<T>

java.lang.Object
  extended by com.hp.hpl.jena.util.iterator.NiceIterator<T>
      extended by com.hp.hpl.jena.util.iterator.WrappedIterator<T>
          extended by com.hp.hpl.jena.util.iterator.UniqueExtendedIterator<T>
All Implemented Interfaces:
ClosableIterator<T>, ExtendedIterator<T>, java.util.Iterator<T>

public class UniqueExtendedIterator<T>
extends WrappedIterator<T>

A variant on the closable/extended iterator that filters out duplicate values. There is one complication that the value which filtering is done on might not be the actual value to be returned by the iterator.

Version:
$Revision: 1.2 $ on $Date: 2009/08/08 11:25:31 $
Author:
Dave Reynolds

Constructor Summary
UniqueExtendedIterator(java.util.Iterator<T> underlying)
          Constructor.
 
Method Summary
static
<T> ExtendedIterator<T>
create(java.util.Iterator<T> it)
          Factory method for generating an iterator that is guaranteed only to return one instance of every result from the wrapped iterator it.
 boolean hasNext()
          hasNext: defer to the base iterator
 T next()
          next: defer to the base iterator
 
Methods inherited from class com.hp.hpl.jena.util.iterator.WrappedIterator
close, close, createNoRemove, forTestingOnly_getBase, remove
 
Methods inherited from class com.hp.hpl.jena.util.iterator.NiceIterator
andThen, andThen, asList, asSet, emptyIterator, filterDrop, filterKeep, mapWith, removeNext, toList, toSet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniqueExtendedIterator

public UniqueExtendedIterator(java.util.Iterator<T> underlying)
Constructor. Note the use of create(java.util.Iterator) as reliable means of creating a unique iterator without double-wrapping iterators that are already unique iterators.

Method Detail

create

public static <T> ExtendedIterator<T> create(java.util.Iterator<T> it)
Factory method for generating an iterator that is guaranteed only to return one instance of every result from the wrapped iterator it.

Parameters:
it - An iterator to wrap
Returns:
A iterator that returns the elements of the wrapped iterator exactly once. If it is already a unique extended iteator, it is not further wrapped.

hasNext

public boolean hasNext()
Description copied from class: WrappedIterator
hasNext: defer to the base iterator

Specified by:
hasNext in interface java.util.Iterator<T>
Overrides:
hasNext in class WrappedIterator<T>
See Also:
Iterator.hasNext()

next

public T next()
Description copied from class: WrappedIterator
next: defer to the base iterator

Specified by:
next in interface java.util.Iterator<T>
Overrides:
next in class WrappedIterator<T>
See Also:
Iterator.next()


Copyright ? 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP