Iterator. Except as noted, each method has a corresponding Iterable-based method in the
Iterables class.
Performance notes: Unless otherwise noted, all of the iterators produced in this class are lazy, which means that they only advance the backing iteration when absolutely necessary.
See the Guava User Guide section on Iterators.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | |
| private static enum | Iterators.EmptyModifiableIterator
This is an enum singleton rather than an anonymous class so ProGuard can figure out it's only referenced by emptyModifiableIterator(). |
| private static class | Iterators.MergingIterator<T extends @Nullable Object>
An iterator that performs a lazy N-way merge, calculating the next value each time the iterator is polled. |
| private static class | Iterators.PeekingImpl<E extends @Nullable Object>
Implementation of PeekingIterator that avoids peeking unless necessary. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static <T extends @Nullable Object> boolean | Returns: true if collection was modified as a result of this operationAdds all elements in |
| public static int | |
| public static <T extends @Nullable Object> boolean | |
| public static <T extends @Nullable Object> boolean | |
| public static <T extends @Nullable Object> Enumeration | |
| pack-priv static <T extends @Nullable Object> ListIterator | |
| pack-priv static void | |
| pack-priv static void | |
| public static <T extends @Nullable Object> Iterator | |
| public static <T extends @Nullable Object> Iterator | |
| public static <T extends @Nullable Object> Iterator | |
| public static <T extends @Nullable Object> Iterator | |
| public static <T extends @Nullable Object> Iterator | |
| pack-priv static <T extends @Nullable Object> Iterator | concatNoDefensiveCopy(Iterator<? extends T>... inputs)
Concats a varargs array of iterators without making a defensive copy of the array. |
| private static <I extends Iterator | consumingForArray(@Nullable I... elements)
Returns an Iterator that walks the specified array, nulling out elements behind it. |
| public static <T extends @Nullable Object> Iterator | Returns: an iterator that removes and returns elements from the supplied iteratorthe iterator to remove and return elements from iterator)Returns a view of the supplied |
| public static boolean | |
| public static <T extends @Nullable Object> Iterator | |
| public static <T extends @Nullable Object> Iterator | |
| public static boolean | elementsEqual(Iterator<?> iterator1, Iterator<?> iterator2)
Determines whether two iterators contain equal elements in the same order. |
| pack-priv static <T extends @Nullable Object> UnmodifiableIterator | |
| pack-priv static <T extends @Nullable Object> UnmodifiableListIterator | |
| pack-priv static <T extends @Nullable Object> Iterator | emptyModifiableIterator()
Returns the empty |
| public static <T extends @Nullable Object> UnmodifiableIterator | |
| public static <T> UnmodifiableIterator | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> UnmodifiableIterator | |
| pack-priv static <T extends @Nullable Object> UnmodifiableListIterator | forArray(T[] array, int offset, int length, int index)
Returns a list iterator containing the elements in the specified range of |
| public static <T extends @Nullable Object> UnmodifiableIterator | |
| public static int | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | Returns: the element at the specified position initerator or defaultValue if
iterator produces fewer than position + 1 elements.position of the element to return position, T the default value to return if the iterator is empty or if defaultValue)position
is greater than the number of elements remaining in iteratorAdvances |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | getOnlyElement(Iterator<? extends T> iterator, T defaultValue)
Returns the single element contained in |
| public static <T extends @Nullable Object> int | |
| public static <T extends @Nullable Object> Iterator | |
| public static <T extends @Nullable Object> UnmodifiableIterator | mergeSorted(Iterable<? extends Iterator<? extends T>> iterators, Comparator<? super T> comparator)
Returns an iterator over the merged contents of all given |
| public static <T extends @Nullable Object> UnmodifiableIterator | Returns: an iterator of immutable lists containing the elements ofiterator divided into
partitions (the final iterable may have trailing null elements)the iterator to return a partitioned view of iterator, int the desired size of each partition size)Divides an iterator into unmodifiable sublists of the given size, padding the final iterator with null values if necessary. |
| public static <T extends @Nullable Object> UnmodifiableIterator | Returns: an iterator of immutable lists containing the elements ofiterator divided into
partitionsthe iterator to return a partitioned view of iterator, int the desired size of each partition (the last may be smaller) size)Divides an iterator into unmodifiable sublists of the given size (the final list may be smaller). |
| private static <T extends @Nullable Object> UnmodifiableIterator | |
| public static <T extends @Nullable Object> PeekingIterator | Returns: a peeking iterator backed by that iterator. Apart from the additionalPeekingIterator#peek() method, this iterator behaves exactly the same as iterator.the backing iterator. The iterator)PeekingIterator assumes ownership of this
iterator, so users should cease making direct calls to it after calling this method.Returns a |
| public static <T extends @Nullable Object> PeekingIterator | peekingIterator(PeekingIterator<T> iterator)
Deprecated
no need to use this
Simply returns its argument.
|
| pack-priv static <T extends @Nullable Object> T | |
| public static boolean | Returns: true if any element was removed from iteratorthe iterator to (potentially) remove elements from removeFrom, Collection<?> the elements to remove elementsToRemove)Traverses an iterator and removes every element that belongs to the provided collection. |
| public static <T extends @Nullable Object> boolean | Returns: true if any elements were removed from the iteratorthe iterator to (potentially) remove elements from removeFrom, Predicate<? super T> a predicate that determines whether an element should be removed predicate)Removes every element that satisfies the provided predicate from the iterator. |
| public static boolean | Returns: true if any element was removed from iteratorthe iterator to (potentially) remove elements from removeFrom, Collection<?> the elements to retain elementsToRetain)Traverses an iterator and removes every element that does not belong to the provided collection. |
| public static <T extends @Nullable Object> UnmodifiableIterator | |
| public static int | |
| public static <T extends @Nullable Object> T[] | |
| public static String | |
| public static <F extends @Nullable Object, T extends @Nullable Object> Iterator | |
| public static <T> Optional | |
| public static <T extends @Nullable Object> UnmodifiableIterator | |
| public static <T extends @Nullable Object> UnmodifiableIterator | unmodifiableIterator(UnmodifiableIterator<T> iterator)
Deprecated
no need to use this
Simply returns its argument.
|