Iterable. Except as noted, each method has a corresponding Iterator-based method
in the Iterators class.
Java 8+ users: several common uses for this class are now more comprehensively
addressed by the new java. library. Read the method documentation below
for comparisons. This class is not being deprecated, but we gently encourage you to migrate to
streams.
Performance notes: Unless otherwise noted, all of the iterables produced in this class are lazy, which means that their iterators only advance the backing iteration when absolutely necessary.
See the Guava User Guide article on Iterables.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| 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 operation.Adds all elements in |
| public static <T extends @Nullable Object> boolean | |
| public static <T extends @Nullable Object> boolean | |
| private static <E extends @Nullable Object> Collection | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> Iterable | Returns: a view of the supplied iterable that wraps each generated iterator throughIterators#consumingIterator(Iterator); for queues, an iterable that generates iterators
that return and consume the queue's elements in queue orderthe iterable to wrap iterable)Returns a view of the supplied iterable that wraps each generated |
| public static boolean | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> Iterable | cycle(T... elements)
Returns an iterable whose iterators cycle indefinitely over the provided elements. |
| public static boolean | elementsEqual(Iterable<?> iterable1, Iterable<?> iterable2)
Determines whether two iterables contain equal elements in the same order. |
| public static <T extends @Nullable Object> Iterable | |
| public static <T> Iterable | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| public static int | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | Returns: the element at the specified position initerable or defaultValue if
iterable contains fewer than position + 1 elements.position of the element to return position, T the default value to return if defaultValue)position is greater than or equal to
the size of the iterableReturns the element at the specified position in an iterable or a default value otherwise. |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| private static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | |
| public static <T extends @Nullable Object> T | getOnlyElement(Iterable<? extends T> iterable, T defaultValue)
Returns the single element contained in |
| public static <T extends @Nullable Object> int | |
| public static boolean | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> Iterable | mergeSorted(final Iterable<? extends Iterable<? extends T>> iterables, final Comparator<? super T> comparator)
Returns an iterable over the merged contents of all given |
| public static <T extends @Nullable Object> Iterable | Returns: an iterable of unmodifiable lists containing the elements ofiterable divided
into partitions (the final iterable may have trailing null elements)the iterable to return a partitioned view of iterable, final int the desired size of each partition size)Divides an iterable into unmodifiable sublists of the given size, padding the final iterable with null values if necessary. |
| public static <T extends @Nullable Object> Iterable | Returns: an iterable of unmodifiable lists containing the elements ofiterable divided
into partitionsthe iterable to return a partitioned view of iterable, final int the desired size of each partition (the last may be smaller) size)Divides an iterable into unmodifiable sublists of the given size (the final iterable may be smaller). |
| public static boolean | Returns: true if any element was removed from iterablethe iterable to (potentially) remove elements from removeFrom, Collection<?> the elements to remove elementsToRemove)Removes, from an iterable, every element that belongs to the provided collection. |
| pack-priv static <T extends @Nullable Object> T | removeFirstMatching(Iterable<T> removeFrom, Predicate<? super T> predicate)
Removes and returns the first matching element, or returns |
| public static <T extends @Nullable Object> boolean | Returns: true if any elements were removed from the iterablethe iterable to (potentially) remove elements from removeFrom, Predicate<? super T> a predicate that determines whether an element should be removed predicate)Removes, from an iterable, every element that satisfies the provided predicate. |
| public static boolean | Returns: true if any element was removed from iterablethe iterable to (potentially) remove elements from removeFrom, Collection<?> the elements to retain elementsToRetain)Removes, from an iterable, every element that does not belong to the provided collection. |
| public static int | |
| public static <T extends @Nullable Object> Iterable | |
| public static <T extends @Nullable Object> T[] | |
| pack-priv static <T extends @Nullable Object> T[] | |
| pack-priv static @Nullable Object[] | |
| public static String | |
| public static <F extends @Nullable Object, T extends @Nullable Object> Iterable | |
| public static <T> Optional | |
| public static <T extends @Nullable Object> Iterable | |
| public static <E> Iterable | unmodifiableIterable(ImmutableCollection<E> iterable)
Deprecated
no need to use this
Simply returns its argument.
|