public class Iterables extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Iterables.Filter<T> |
static interface |
Iterables.Mapper<T,S> |
static interface |
Iterables.Reducer<T,S> |
Constructor and Description |
---|
Iterables() |
Modifier and Type | Method and Description |
---|---|
static <T> Iterable<T> |
filter(Iterable<T> input,
Iterables.Filter<T> filter) |
static <T> T |
first(Iterable<T> collection) |
static <T> com.google.common.base.Optional<T> |
first(Iterable<T> collection,
Iterables.Filter<T> filter) |
static <T,S> Iterable<S> |
map(Iterable<T> input,
Iterables.Mapper<T,S> mapper) |
static <T,S> List<S> |
mapList(List<T> input,
Iterables.Mapper<T,S> mapper) |
static <T,S> S |
reduce(Iterable<T> collection,
S initialValue,
Iterables.Reducer<T,S> reducer) |
public static <T> Iterable<T> filter(Iterable<T> input, Iterables.Filter<T> filter)
input
- An input iterable.filter
- A filtering function.public static <T,S> Iterable<S> map(Iterable<T> input, Iterables.Mapper<T,S> mapper)
input
- An input Iterable.mapper
- A map function.public static <T,S> List<S> mapList(List<T> input, Iterables.Mapper<T,S> mapper)
input
- An input list.mapper
- A map function.public static <T,S> S reduce(Iterable<T> collection, S initialValue, Iterables.Reducer<T,S> reducer)
collection
- An iterable.initialValue
- An initial value.reducer
- A reduction function.public static <T> com.google.common.base.Optional<T> first(Iterable<T> collection, Iterables.Filter<T> filter)
collection
- An iterable.filter
- A filter.public static <T> T first(Iterable<T> collection)
collection
- An iterable (non-empty).Copyright © 2016. All rights reserved.