javadoc.com.google.common.collect.AbstractLinkedIterator.html Maven / Gradle / Ivy
The newest version!
AbstractLinkedIterator (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.google.common.collect
Class AbstractLinkedIterator<T>
java.lang.Object
com.google.common.collect.UnmodifiableIterator<T>
com.google.common.collect.AbstractLinkedIterator<T>
- All Implemented Interfaces:
- Iterator<T>
@Beta
@GwtCompatible
public abstract class AbstractLinkedIterator<T>
- extends UnmodifiableIterator<T>
This class provides a skeletal implementation of the Iterator
interface for sequences whose next element can always be derived from the
previous element. Null elements are not supported, nor is the
UnmodifiableIterator.remove()
method.
Example:
Iterator<Integer> powersOfTwo = new AbstractLinkedIterator<Integer>(1) {
protected Integer computeNext(Integer previous) {
return (previous == 1 << 30) ? null : previous * 2;
}
};
- Since:
- 8.0
- Author:
- Chris Povirk
Constructor Summary | |
---|---|
protected |
AbstractLinkedIterator(T firstOrNull)
Creates a new iterator with the given first element, or, if firstOrNull is null, creates a new empty iterator. |
Method Summary | |
---|---|
protected abstract T |
computeNext(T previous)
Returns the element that follows previous , or returns null
if no elements remain. |
boolean |
hasNext()
|
T |
next()
|
Methods inherited from class com.google.common.collect.UnmodifiableIterator |
---|
remove |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
AbstractLinkedIterator
protected AbstractLinkedIterator(@Nullable T firstOrNull)
- Creates a new iterator with the given first element, or, if
firstOrNull
is null, creates a new empty iterator.
Method Detail |
---|
computeNext
protected abstract T computeNext(T previous)
- Returns the element that follows
previous
, or returnsnull
if no elements remain. This method is invoked during each call tonext()
in order to compute the result of a future call tonext()
.
hasNext
public final boolean hasNext()
next
public final T next()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy