Class ListIteratorWrapper<E>
java.lang.Object
org.apache.commons.collections4.iterators.ListIteratorWrapper<E>
- Type Parameters:
- E- the type of elements in this iterator.
- All Implemented Interfaces:
- Iterator<E>,- ListIterator<E>,- OrderedIterator<E>,- ResettableIterator<E>,- ResettableListIterator<E>
Converts an 
Iterator into a ResettableListIterator.
 For plain Iterators this is accomplished by caching the returned
 elements.  This class can also be used to simply add
 ResettableIterator
 functionality to a given ListIterator.
 
 The ListIterator interface has additional useful methods
 for navigation - previous() and the index methods.
 This class allows a regular Iterator to behave as a
 ListIterator. It achieves this by building a list internally
 of as the underlying iterator is traversed.
 
 The optional operations of ListIterator are not supported for plain Iterators.
 
This class implements ResettableListIterator from Commons Collections 3.2.
- Since:
- 2.1
- 
Constructor SummaryConstructorsConstructorDescriptionListIteratorWrapper(Iterator<? extends E> iterator) Constructs a newListIteratorWrapperthat will wrap the given iterator.
- 
Method SummaryModifier and TypeMethodDescriptionvoidbooleanhasNext()Returns true if there are more elements in the iterator.booleanReturns true if there are previous elements in the iterator.next()Returns the next element from the iterator.intReturns the index of the next element.previous()Returns the previous element.intReturns the index of the previous element.voidremove()Removes the last element that was returned bynext()orprevious()from the underlying collection.voidreset()Resets this iterator back to the position at which the iterator was created.voidMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.IteratorforEachRemaining
- 
Constructor Details- 
ListIteratorWrapperConstructs a newListIteratorWrapperthat will wrap the given iterator.- Parameters:
- iterator- the iterator to wrap
- Throws:
- NullPointerException- if the iterator is null
 
 
- 
- 
Method Details- 
add- Specified by:
- addin interface- ListIterator<E>
- Parameters:
- obj- the object to add
- Throws:
- UnsupportedOperationException- if the underlying iterator is not of type- ListIterator
 
- 
hasNext
- 
hasPreviousReturns true if there are previous elements in the iterator.- Specified by:
- hasPreviousin interface- ListIterator<E>
- Specified by:
- hasPreviousin interface- OrderedIterator<E>
- Returns:
- true if there are previous elements
 
- 
nextReturns the next element from the iterator.- Specified by:
- nextin interface- Iterator<E>
- Specified by:
- nextin interface- ListIterator<E>
- Returns:
- the next element from the iterator
- Throws:
- NoSuchElementException- if there are no more elements
 
- 
nextIndexReturns the index of the next element.- Specified by:
- nextIndexin interface- ListIterator<E>
- Returns:
- the index of the next element
 
- 
previousReturns the previous element.- Specified by:
- previousin interface- ListIterator<E>
- Specified by:
- previousin interface- OrderedIterator<E>
- Returns:
- the previous element
- Throws:
- NoSuchElementException- if there are no previous elements
 
- 
previousIndexReturns the index of the previous element.- Specified by:
- previousIndexin interface- ListIterator<E>
- Returns:
- the index of the previous element
 
- 
removeRemoves the last element that was returned bynext()orprevious()from the underlying collection. This call can only be made once per call tonextorpreviousand only ifadd(Object)was not called in between.- Specified by:
- removein interface- Iterator<E>
- Specified by:
- removein interface- ListIterator<E>
- Throws:
- IllegalStateException- if- nextor- previoushave not been called before, or if- removeor- addhave been called after the last call to- nextor- previous
 
- 
resetResets this iterator back to the position at which the iterator was created.- Specified by:
- resetin interface- ResettableIterator<E>
- Since:
- 3.2
 
- 
set- Specified by:
- setin interface- ListIterator<E>
- Parameters:
- obj- the object to set
- Throws:
- UnsupportedOperationException- if the underlying iterator is not of type- ListIterator
 
 
-