public final class Iterables extends Object
Note: This class includes codes copied from Apache Commons Lang, Google Guava and other open source projects under the Apache License 2.0. The methods copied from other libraries/frameworks/projects may be modified in this class.
This is a utility class for iterable data structures, including Collection/Array/Iterator.
The methods in this class should only read the input Collection/Array/Iterator parameters, not modify them.
N,
Iterators,
Maps,
StringUtil| Modifier and Type | Class and Description |
|---|---|
static class |
Iterables.SetView<E> |
| Modifier and Type | Method and Description |
|---|---|
static <T extends Number> |
averageDouble(Collection<? extends T> c)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageDouble(Collection<? extends T> c,
int fromIndex,
int toIndex)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageDouble(Collection<? extends T> c,
int fromIndex,
int toIndex,
Throwables.ToDoubleFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageDouble(Collection<? extends T> c,
Throwables.ToDoubleFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageDouble(T[] a)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageDouble(T[] a,
int fromIndex,
int toIndex)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageDouble(T[] a,
int fromIndex,
int toIndex,
Throwables.ToDoubleFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageDouble(T[] a,
Throwables.ToDoubleFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageInt(Collection<? extends T> c)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageInt(Collection<? extends T> c,
int fromIndex,
int toIndex)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageInt(Collection<? extends T> c,
int fromIndex,
int toIndex,
Throwables.ToIntFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageInt(Collection<? extends T> c,
Throwables.ToIntFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageInt(T[] a)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageInt(T[] a,
int fromIndex,
int toIndex)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageInt(T[] a,
int fromIndex,
int toIndex,
Throwables.ToIntFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageInt(T[] a,
Throwables.ToIntFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageLong(Collection<? extends T> c)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageLong(Collection<? extends T> c,
int fromIndex,
int toIndex)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageLong(Collection<? extends T> c,
int fromIndex,
int toIndex,
Throwables.ToLongFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageLong(Collection<? extends T> c,
Throwables.ToLongFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageLong(T[] a)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T extends Number> |
averageLong(T[] a,
int fromIndex,
int toIndex)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageLong(T[] a,
int fromIndex,
int toIndex,
Throwables.ToLongFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <T,E extends Exception> |
averageLong(T[] a,
Throwables.ToLongFunction<? super T,E> func)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex. |
static <E> Iterables.SetView<E> |
difference(Set<E> set1,
Set<?> set2)
Returns an unmodifiable view of the difference of two sets.
|
static <T,E extends Exception> |
findFirstAndLast(Collection<? extends T> c,
Throwables.Predicate<? super T,E> predicate)
Find first and last.
|
static <T,E extends Exception,E2 extends Exception> |
findFirstAndLast(Collection<? extends T> c,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast)
Find first and last.
|
static <T,E extends Exception> |
findFirstAndLast(T[] a,
Throwables.Predicate<? super T,E> predicate)
Find first and last.
|
static <T,E extends Exception,E2 extends Exception> |
findFirstAndLast(T[] a,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast)
Find first and last.
|
static <T,E extends Exception> |
findFirstAndLastIndex(Collection<? extends T> c,
Throwables.Predicate<? super T,E> predicate)
Find first and last index.
|
static <T,E extends Exception,E2 extends Exception> |
findFirstAndLastIndex(Collection<? extends T> c,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast)
Find first and last index.
|
static <T,E extends Exception> |
findFirstAndLastIndex(T[] a,
Throwables.Predicate<? super T,E> predicate)
Find first and last index.
|
static <T,E extends Exception,E2 extends Exception> |
findFirstAndLastIndex(T[] a,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast)
Find first and last index.
|
static <T,E extends Exception,E2 extends Exception> |
findFirstOrLast(Collection<? extends T> c,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast)
Find first or last.
|
static <T,E extends Exception,E2 extends Exception> |
findFirstOrLast(T[] a,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast)
Find first or last.
|
static <T,E extends Exception,E2 extends Exception> |
findFirstOrLastIndex(Collection<? extends T> c,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast) |
static <T,E extends Exception,E2 extends Exception> |
findFirstOrLastIndex(T[] a,
Throwables.Predicate<? super T,E> predicateForFirst,
Throwables.Predicate<? super T,E2> predicateForLast)
Find first or last index.
|
static u.OptionalInt |
indexOf(Collection<?> c,
Object objToFind) |
static u.OptionalInt |
indexOf(Object[] a,
Object objToFind) |
static <E> Iterables.SetView<E> |
intersection(Set<E> set1,
Set<?> set2)
Returns an unmodifiable view of the intersection of two sets.
|
static <T extends Comparable<? super T>> |
kthLargest(Collection<? extends T> c,
int k)
Returns
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k. |
static <T> u.Nullable<T> |
kthLargest(Collection<? extends T> c,
int k,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k. |
static <T extends Comparable<? super T>> |
kthLargest(T[] a,
int k)
Returns
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k. |
static <T> u.Nullable<T> |
kthLargest(T[] a,
int k,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k. |
static u.OptionalInt |
lastIndexOf(Collection<?> c,
Object objToFind) |
static u.OptionalInt |
lastIndexOf(Object[] a,
Object objToFind) |
static u.OptionalByte |
max(byte... a)
Returns
OptionalByte.empty() if the specified Array/Collection is null or empty. |
static u.OptionalChar |
max(char... a)
Returns
OptionalChar.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
max(Collection<? extends T> c)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
max(Collection<? extends T> c,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static u.OptionalDouble |
max(double... a)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty. |
static u.OptionalFloat |
max(float... a)
Returns
OptionalFloat.empty() if the specified Array/Collection is null or empty. |
static u.OptionalInt |
max(int... a)
Returns
OptionalInt.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
max(Iterator<? extends T> iter)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
max(Iterator<? extends T> iter,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static u.OptionalLong |
max(long... a)
Returns
OptionalLong.empty() if the specified Array/Collection is null or empty. |
static u.OptionalShort |
max(short... a)
Returns
OptionalShort.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
max(T[] a)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
max(T[] a,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
maxBy(Collection<? extends T> c,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
maxBy(Iterator<? extends T> iter,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
maxBy(T[] a,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
median(Collection<? extends T> c)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
median(Collection<? extends T> c,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
median(T[] a)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
median(T[] a,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
medianBy(Collection<? extends T> c,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
medianBy(T[] a,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static u.OptionalByte |
min(byte... a)
Returns
OptionalByte.empty() if the specified Array/Collection is null or empty. |
static u.OptionalChar |
min(char... a)
Returns
OptionalChar.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
min(Collection<? extends T> c)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
min(Collection<? extends T> c,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static u.OptionalDouble |
min(double... a)
Returns
OptionalDouble.empty() if the specified Array/Collection is null or empty. |
static u.OptionalFloat |
min(float... a)
Returns
OptionalFloat.empty() if the specified Array/Collection is null or empty. |
static u.OptionalInt |
min(int... a)
Returns
OptionalInt.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
min(Iterator<? extends T> iter)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
min(Iterator<? extends T> iter,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static u.OptionalLong |
min(long... a)
Returns
OptionalLong.empty() if the specified Array/Collection is null or empty. |
static u.OptionalShort |
min(short... a)
Returns
OptionalShort.empty() if the specified Array/Collection is null or empty. |
static <T extends Comparable<? super T>> |
min(T[] a)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
min(T[] a,
Comparator<? super T> cmp)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
minBy(Collection<? extends T> c,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
minBy(Iterator<? extends T> iter,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> u.Nullable<T> |
minBy(T[] a,
Function<? super T,? extends Comparable> keyMapper)
Returns
Nullable.empty() if the specified Array/Collection is null or empty. |
static <T> boolean |
padLeft(List<T> list,
int minLen,
T objToAdd) |
static <T> boolean |
padRight(Collection<T> c,
int minLen,
T objToAdd) |
static <E> Iterables.SetView<E> |
symmetricDifference(Set<? extends E> set1,
Set<? extends E> set2)
Returns an unmodifiable view of the symmetric difference of two sets.
|
static <E> Iterables.SetView<E> |
union(Set<? extends E> set1,
Set<? extends E> set2)
Returns an unmodifiable view of the union of two sets.
|
@SafeVarargs public static u.OptionalChar min(char... a)
OptionalChar.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalByte min(byte... a)
OptionalByte.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalShort min(short... a)
OptionalShort.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalInt min(int... a)
OptionalInt.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalLong min(long... a)
OptionalLong.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalFloat min(float... a)
OptionalFloat.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalDouble min(double... a)
OptionalDouble.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalChar max(char... a)
OptionalChar.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalByte max(byte... a)
OptionalByte.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalShort max(short... a)
OptionalShort.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalInt max(int... a)
OptionalInt.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalLong max(long... a)
OptionalLong.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalFloat max(float... a)
OptionalFloat.empty() if the specified Array/Collection is null or empty.a - @SafeVarargs public static u.OptionalDouble max(double... a)
OptionalDouble.empty() if the specified Array/Collection is null or empty.a - public static <T extends Comparable<? super T>> u.Nullable<T> min(T[] a)
Nullable.empty() if the specified Array/Collection is null or empty.a - public static <T> u.Nullable<T> min(T[] a, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.a - cmp - public static <T extends Comparable<? super T>> u.Nullable<T> min(Collection<? extends T> c)
Nullable.empty() if the specified Array/Collection is null or empty.c - public static <T> u.Nullable<T> min(Collection<? extends T> c, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.c - cmp - public static <T extends Comparable<? super T>> u.Nullable<T> min(Iterator<? extends T> iter)
Nullable.empty() if the specified Array/Collection is null or empty.iter - public static <T> u.Nullable<T> min(Iterator<? extends T> iter, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.iter - cmp - public static <T> u.Nullable<T> minBy(T[] a, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.a - cmp - public static <T> u.Nullable<T> minBy(Collection<? extends T> c, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.c - cmp - public static <T> u.Nullable<T> minBy(Iterator<? extends T> iter, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.iter - cmp - public static <T extends Comparable<? super T>> u.Nullable<T> max(T[] a)
Nullable.empty() if the specified Array/Collection is null or empty.a - public static <T> u.Nullable<T> max(T[] a, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.a - cmp - public static <T extends Comparable<? super T>> u.Nullable<T> max(Collection<? extends T> c)
Nullable.empty() if the specified Array/Collection is null or empty.c - public static <T> u.Nullable<T> max(Collection<? extends T> c, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.c - public static <T extends Comparable<? super T>> u.Nullable<T> max(Iterator<? extends T> iter)
Nullable.empty() if the specified Array/Collection is null or empty.iter - public static <T> u.Nullable<T> max(Iterator<? extends T> iter, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.iter - cmp - public static <T> u.Nullable<T> maxBy(T[] a, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.a - cmp - public static <T> u.Nullable<T> maxBy(Collection<? extends T> c, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.c - cmp - public static <T> u.Nullable<T> maxBy(Iterator<? extends T> iter, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.iter - cmp - public static <T extends Comparable<? super T>> u.Nullable<T> median(T[] a)
Nullable.empty() if the specified Array/Collection is null or empty.a - public static <T extends Comparable<? super T>> u.Nullable<T> median(Collection<? extends T> c)
Nullable.empty() if the specified Array/Collection is null or empty.c - public static <T> u.Nullable<T> median(T[] a, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.a - cmp - public static <T> u.Nullable<T> median(Collection<? extends T> c, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty.c - cmp - public static <T> u.Nullable<T> medianBy(T[] a, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.a - keyMapper - public static <T> u.Nullable<T> medianBy(Collection<? extends T> c, Function<? super T,? extends Comparable> keyMapper)
Nullable.empty() if the specified Array/Collection is null or empty.c - keyMapper - public static <T extends Comparable<? super T>> u.Nullable<T> kthLargest(Collection<? extends T> c, int k)
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k.c - k - public static <T extends Comparable<? super T>> u.Nullable<T> kthLargest(T[] a, int k)
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k.a - k - public static <T> u.Nullable<T> kthLargest(Collection<? extends T> c, int k, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k.c - k - cmp - public static <T> u.Nullable<T> kthLargest(T[] a, int k, Comparator<? super T> cmp)
Nullable.empty() if the specified Array/Collection is null or empty, or its length/size is less than k.a - k - cmp - public static <T extends Number> u.OptionalDouble averageInt(T[] a)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - a - public static <T extends Number> u.OptionalDouble averageInt(T[] a, int fromIndex, int toIndex)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - a - fromIndex - toIndex - public static <T,E extends Exception> u.OptionalDouble averageInt(T[] a, Throwables.ToIntFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - a - func - E - the eE extends Exceptionpublic static <T,E extends Exception> u.OptionalDouble averageInt(T[] a, int fromIndex, int toIndex, Throwables.ToIntFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - a - fromIndex - toIndex - func - E - the eE extends Exceptionpublic static <T extends Number> u.OptionalDouble averageInt(Collection<? extends T> c)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - c - public static <T extends Number> u.OptionalDouble averageInt(Collection<? extends T> c, int fromIndex, int toIndex)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - c - fromIndex - toIndex - public static <T,E extends Exception> u.OptionalDouble averageInt(Collection<? extends T> c, Throwables.ToIntFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - c - func - E - the eE extends Exceptionpublic static <T,E extends Exception> u.OptionalDouble averageInt(Collection<? extends T> c, int fromIndex, int toIndex, Throwables.ToIntFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - c - fromIndex - toIndex - func - E - the eE extends Exceptionpublic static <T extends Number> u.OptionalDouble averageLong(T[] a)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - a - public static <T extends Number> u.OptionalDouble averageLong(T[] a, int fromIndex, int toIndex)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - a - fromIndex - toIndex - public static <T,E extends Exception> u.OptionalDouble averageLong(T[] a, Throwables.ToLongFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - a - func - E - the eE extends Exceptionpublic static <T,E extends Exception> u.OptionalDouble averageLong(T[] a, int fromIndex, int toIndex, Throwables.ToLongFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - a - fromIndex - toIndex - func - E - the eE extends Exceptionpublic static <T extends Number> u.OptionalDouble averageLong(Collection<? extends T> c)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - c - public static <T extends Number> u.OptionalDouble averageLong(Collection<? extends T> c, int fromIndex, int toIndex)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - c - fromIndex - toIndex - public static <T,E extends Exception> u.OptionalDouble averageLong(Collection<? extends T> c, Throwables.ToLongFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - c - func - E - the eE extends Exceptionpublic static <T,E extends Exception> u.OptionalDouble averageLong(Collection<? extends T> c, int fromIndex, int toIndex, Throwables.ToLongFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - c - fromIndex - toIndex - func - E - the eE extends Exceptionpublic static <T extends Number> u.OptionalDouble averageDouble(T[] a)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - a - public static <T extends Number> u.OptionalDouble averageDouble(T[] a, int fromIndex, int toIndex)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - a - fromIndex - toIndex - public static <T,E extends Exception> u.OptionalDouble averageDouble(T[] a, Throwables.ToDoubleFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - a - func - E - the eE extends Exceptionpublic static <T,E extends Exception> u.OptionalDouble averageDouble(T[] a, int fromIndex, int toIndex, Throwables.ToDoubleFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - a - fromIndex - toIndex - func - E - the eE extends Exceptionpublic static <T extends Number> u.OptionalDouble averageDouble(Collection<? extends T> c)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - c - public static <T extends Number> u.OptionalDouble averageDouble(Collection<? extends T> c, int fromIndex, int toIndex)
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - c - fromIndex - toIndex - public static <T,E extends Exception> u.OptionalDouble averageDouble(Collection<? extends T> c, Throwables.ToDoubleFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - c - func - E - the eE extends Exceptionpublic static <T,E extends Exception> u.OptionalDouble averageDouble(Collection<? extends T> c, int fromIndex, int toIndex, Throwables.ToDoubleFunction<? super T,E> func) throws E extends Exception
OptionalDouble.empty() if the specified Array/Collection is null or empty, or fromIndex == toIndex.T - E - c - fromIndex - toIndex - func - E - the eE extends Exceptionpublic static u.OptionalInt indexOf(Object[] a, Object objToFind)
public static u.OptionalInt indexOf(Collection<?> c, Object objToFind)
public static u.OptionalInt lastIndexOf(Object[] a, Object objToFind)
public static u.OptionalInt lastIndexOf(Collection<?> c, Object objToFind)
public static <T,E extends Exception,E2 extends Exception> u.OptionalInt findFirstOrLastIndex(T[] a, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
T - the generic typeE - the element typeE2 - the generic typea - the apredicateForFirst - the predicate for firstpredicateForLast - the predicate for lastE - the eE2 - the e2E extends Exceptionpublic static <T,E extends Exception,E2 extends Exception> u.OptionalInt findFirstOrLastIndex(Collection<? extends T> c, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
E extends Exceptionpublic static <T,E extends Exception> Pair<u.OptionalInt,u.OptionalInt> findFirstAndLastIndex(T[] a, Throwables.Predicate<? super T,E> predicate) throws E extends Exception
T - the generic typeE - the element typea - the apredicate - the predicateE - the eE extends Exceptionpublic static <T,E extends Exception,E2 extends Exception> Pair<u.OptionalInt,u.OptionalInt> findFirstAndLastIndex(T[] a, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
T - the generic typeE - the element typeE2 - the generic typea - the apredicateForFirst - the predicate for firstpredicateForLast - the predicate for lastE - the eE2 - the e2E extends Exceptionpublic static <T,E extends Exception> Pair<u.OptionalInt,u.OptionalInt> findFirstAndLastIndex(Collection<? extends T> c, Throwables.Predicate<? super T,E> predicate) throws E extends Exception
T - the generic typeE - the element typec - the cpredicate - the predicateE - the eE extends Exceptionpublic static <T,E extends Exception,E2 extends Exception> Pair<u.OptionalInt,u.OptionalInt> findFirstAndLastIndex(Collection<? extends T> c, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
T - the generic typeE - the element typeE2 - the generic typec - the cpredicateForFirst - the predicate for firstpredicateForLast - the predicate for lastE - the eE2 - the e2E extends Exceptionpublic static <T,E extends Exception,E2 extends Exception> u.Nullable<T> findFirstOrLast(T[] a, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
T - the generic typeE - the element typeE2 - the generic typea - the apredicateForFirst - the predicate for firstpredicateForLast - the predicate for lastE - the eE2 - the e2E extends Exceptionpublic static <T,E extends Exception,E2 extends Exception> u.Nullable<T> findFirstOrLast(Collection<? extends T> c, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
T - the generic typeE - the element typeE2 - the generic typec - the cpredicateForFirst - the predicate for firstpredicateForLast - the predicate for lastE - the eE2 - the e2E extends Exceptionpublic static <T,E extends Exception> Pair<u.Nullable<T>,u.Nullable<T>> findFirstAndLast(T[] a, Throwables.Predicate<? super T,E> predicate) throws E extends Exception
T - the generic typeE - the element typea - the apredicate - the predicateE - the eE extends Exceptionpublic static <T,E extends Exception,E2 extends Exception> Pair<u.Nullable<T>,u.Nullable<T>> findFirstAndLast(T[] a, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
T - the generic typeE - the element typeE2 - the generic typea - the apredicateForFirst - the predicate for firstpredicateForLast - the predicate for lastE - the eE2 - the e2E extends Exceptionpublic static <T,E extends Exception> Pair<u.Nullable<T>,u.Nullable<T>> findFirstAndLast(Collection<? extends T> c, Throwables.Predicate<? super T,E> predicate) throws E extends Exception
T - the generic typeE - the element typec - the cpredicate - the predicateE - the eE extends Exceptionpublic static <T,E extends Exception,E2 extends Exception> Pair<u.Nullable<T>,u.Nullable<T>> findFirstAndLast(Collection<? extends T> c, Throwables.Predicate<? super T,E> predicateForFirst, Throwables.Predicate<? super T,E2> predicateForLast) throws E extends Exception, E2 extends Exception
T - the generic typeE - the element typeE2 - the generic typec - the cpredicateForFirst - the predicate for firstpredicateForLast - the predicate for lastE - the eE2 - the e2E extends Exceptionpublic static <T> boolean padLeft(List<T> list, int minLen, T objToAdd)
public static <T> boolean padRight(Collection<T> c, int minLen, T objToAdd)
public static <E> Iterables.SetView<E> union(Set<? extends E> set1, Set<? extends E> set2)
set1, then over each element of set2, in order,
that is not contained in set1.
Results are undefined if set1 and set2 are sets based on different
equivalence relations (as HashSet, TreeSet, and the Map.keySet() of an
IdentityHashMap all are).
public static <E> Iterables.SetView<E> intersection(Set<E> set1, Set<?> set2)
set1.
Results are undefined if set1 and set2 are sets based on different
equivalence relations (as HashSet, TreeSet, and the keySet of an IdentityHashMap all are).
Note: The returned view performs slightly better when set1 is the smaller of
the two sets. If you have reason to believe one of your sets will generally be smaller than the
other, pass it first. Unfortunately, since this method sets the generic type of the returned
set based on the type of the first set passed, this could in rare cases force you to make a
cast, for example:
Set<Object> aFewBadObjects = ...
Set<String> manyBadStrings = ...
// impossible for a non-String to be in the intersection
SuppressWarnings("unchecked")
Set<String> badStrings = (Set) Sets.intersection(
aFewBadObjects, manyBadStrings);
This is unfortunate, but should come up only very rarely.
public static <E> Iterables.SetView<E> difference(Set<E> set1, Set<?> set2)
set1 and not contained by set2. set2
may also contain elements not present in set1; these are simply ignored. The iteration
order of the returned set matches that of set1.
Results are undefined if set1 and set2 are sets based on different
equivalence relations (as HashSet, TreeSet, and the keySet of an IdentityHashMap all are).
public static <E> Iterables.SetView<E> symmetricDifference(Set<? extends E> set1, Set<? extends E> set2)
set1 or set2 but not in
both. The iteration order of the returned set is undefined.
Results are undefined if set1 and set2 are sets based on different
equivalence relations (as HashSet, TreeSet, and the keySet of an IdentityHashMap all are).
Copyright © 2021. All rights reserved.