Package io.atlassian.fugue
Class Iterators
- java.lang.Object
-
- io.atlassian.fugue.Iterators
-
class Iterators extends java.lang.ObjectUtility class for constructing iterables- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classIterators.Abstract<A>A template implementation of theIteratorinterface, so clients can more easily implement Iterator for some patterns of iteration.private static classIterators.EmptyIterator(package private) static interfaceIterators.Peek<A>Marker interface for use in constructing iterators(package private) static interfaceIterators.Peeking<A>Iterator that can examine next without removing itprivate static classIterators.PeekingImpl<A>Implementation of Iterators.Peeking that avoids peeking unless necessary.(package private) static classIterators.Unmodifiable<E>Iterator whereIterators.Unmodifiable.remove()is unsupported.
-
Constructor Summary
Constructors Constructor Description Iterators()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static <A> booleanaddAll(java.util.Collection<A> collectionToModify, java.util.Iterator<? extends A> iterator)Adds all the elements of the iterator to the collectionToModifystatic <A> java.util.Iterator<A>emptyIterator()Iterator with no values inside(package private) static <A> Iterators.Peeking<A>peekingIterator(java.util.Iterator<? extends A> iterator)Wrap an iterator to add support for the peek operation.(package private) static <A> java.util.Iterator<A>singletonIterator(A a)Iterator that returns a single element
-
-
-
Method Detail
-
addAll
static <A> boolean addAll(java.util.Collection<A> collectionToModify, java.util.Iterator<? extends A> iterator)Adds all the elements of the iterator to the collectionToModify- Type Parameters:
A- element type- Parameters:
collectionToModify- collection to add element to, must not be nulliterator- source of elements to add, must not be null- Returns:
- true if any of the elements from iterator were not also in collectionToModify
- Since:
- 3.0
-
peekingIterator
static <A> Iterators.Peeking<A> peekingIterator(java.util.Iterator<? extends A> iterator)
Wrap an iterator to add support for the peek operation. Do not maintain a reference to the iterator passed in as a parameter. Iterators are mutable by nature and this function makes no promises about how or when the input iterator will be mutated.- Type Parameters:
A- element type- Parameters:
iterator- iterator that may not support peek, must not be null- Returns:
- an iterator for which
peekwill return Iterator#next without removing the value from the iterator - Since:
- 3.0
-
singletonIterator
static <A> java.util.Iterator<A> singletonIterator(A a)
Iterator that returns a single element- Type Parameters:
A- element type- Parameters:
a- element to return- Returns:
- iterator returning only a
- Since:
- 3.0
-
emptyIterator
public static <A> java.util.Iterator<A> emptyIterator()
Iterator with no values inside- Type Parameters:
A- element type- Returns:
- empty iterator
- Since:
- 3.0
-
-