I
- the type of element being iterated on inputO
- the type of element returned on outputpublic class TransformListIterator<I,O> extends Object implements ListIterator<O>
TransformListIterator
class provides a useful extension to
the ListIterator
interface in cases where a transforming function
needs to be applied to the iterator before returning any elements.
The implementation provided here creates a list iterator which wraps around the given list iterator. The original list iterator is iterated as this list iterator is being accessed.
TransformIterator
Constructor and Description |
---|
TransformListIterator(ListIterator<? extends I> i)
Constructs a transforming list iterator using an input list iterator.
|
TransformListIterator(ListIterator<? extends I> i,
Transformer<? super I,? extends O> transformer)
Constructs a transforming list iterator using an input list iterator and the
specified transformer.
|
Modifier and Type | Method and Description |
---|---|
void |
add(O o) |
ListIterator<? extends I> |
getIterator()
Gets the iterator this iterator is using.
|
Transformer<? super I,? extends O> |
getTransformer()
Gets the transformer this iterator is using.
|
boolean |
hasNext() |
boolean |
hasPrevious() |
O |
next() |
int |
nextIndex() |
O |
previous() |
int |
previousIndex() |
void |
remove() |
void |
set(O o) |
void |
setIterator(ListIterator<? extends I> iterator)
Sets the iterator for this iterator to use.
|
void |
setTransformer(Transformer<? super I,? extends O> transformer)
Sets the transformer this iterator will use.
|
protected O |
transform(I source)
Transforms the given object using the transformer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public TransformListIterator(ListIterator<? extends I> i)
i
- a list iterator to be transformedpublic TransformListIterator(ListIterator<? extends I> i, Transformer<? super I,? extends O> transformer)
i
- a list iterator to be transformedtransformer
- a transformer objectprotected O transform(I source)
source
- the object to transformpublic boolean hasNext()
hasNext
in interface Iterator<O>
hasNext
in interface ListIterator<O>
ListIterator.hasNext()
public O next()
next
in interface Iterator<O>
next
in interface ListIterator<O>
ListIterator.next()
public void remove()
remove
in interface Iterator<O>
remove
in interface ListIterator<O>
ListIterator.remove()
public boolean hasPrevious()
hasPrevious
in interface ListIterator<O>
ListIterator.hasPrevious()
public O previous()
previous
in interface ListIterator<O>
ListIterator.previous()
public int nextIndex()
nextIndex
in interface ListIterator<O>
ListIterator.nextIndex()
public int previousIndex()
previousIndex
in interface ListIterator<O>
ListIterator.previousIndex()
public void set(O o)
set
in interface ListIterator<O>
ListIterator.set(java.lang.Object)
public void add(O o)
add
in interface ListIterator<O>
ListIterator.add(java.lang.Object)
public ListIterator<? extends I> getIterator()
public void setIterator(ListIterator<? extends I> iterator)
iterator
- the iterator to usepublic Transformer<? super I,? extends O> getTransformer()
public void setTransformer(Transformer<? super I,? extends O> transformer)
transformer
- the transformer to useCopyright (C) 2015-2017 The Helenus Driver Project Authors.