Package com.google.common.collect
Class Collections2.PermutationIterator<E>
- java.lang.Object
-
- com.google.common.collect.UnmodifiableIterator<T>
-
- com.google.common.collect.AbstractIterator<java.util.List<E>>
-
- com.google.common.collect.Collections2.PermutationIterator<E>
-
- All Implemented Interfaces:
java.util.Iterator<java.util.List<E>>
- Enclosing class:
- Collections2
private static class Collections2.PermutationIterator<E> extends AbstractIterator<java.util.List<E>>
-
-
Constructor Summary
Constructors Constructor Description PermutationIterator(java.util.List<E> list)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
calculateNextPermutation()
protected java.util.List<E>
computeNext()
Returns the next element.(package private) void
switchDirection()
-
Methods inherited from class com.google.common.collect.AbstractIterator
endOfData, hasNext, next, peek
-
Methods inherited from class com.google.common.collect.UnmodifiableIterator
remove
-
-
-
-
Field Detail
-
list
final java.util.List<E> list
-
c
final int[] c
-
o
final int[] o
-
j
int j
-
-
Constructor Detail
-
PermutationIterator
PermutationIterator(java.util.List<E> list)
-
-
Method Detail
-
computeNext
protected java.util.List<E> computeNext()
Description copied from class:AbstractIterator
Returns the next element. Note: the implementation must callAbstractIterator.endOfData()
when there are no elements left in the iteration. Failure to do so could result in an infinite loop.The initial invocation of
AbstractIterator.hasNext()
orAbstractIterator.next()
calls this method, as does the first invocation ofhasNext
ornext
following each successful call tonext
. Once the implementation either invokesendOfData
or throws an exception,computeNext
is guaranteed to never be called again.If this method throws an exception, it will propagate outward to the
hasNext
ornext
invocation that invoked this method. Any further attempts to use the iterator will result in anIllegalStateException
.The implementation of this method may not invoke the
hasNext
,next
, orAbstractIterator.peek()
methods on this instance; if it does, anIllegalStateException
will result.- Specified by:
computeNext
in classAbstractIterator<java.util.List<E>>
- Returns:
- the next element if there was one. If
endOfData
was called during execution, the return value will be ignored.
-
calculateNextPermutation
void calculateNextPermutation()
-
switchDirection
void switchDirection()
-
-