public class ERXCollectors extends Object
Collector
that implement various useful reduction
operations related with NSCollection classes.
The following are examples of using the predefined collectors to perform common mutable reduction tasks:
// Accumulate names into a NSArray NSArrayarray = people.stream().map(Person::name).collect(ERXCollectors.toNSArray()); // Accumulate names into a NSSet NSSet set = people.stream().map(Person::name).collect(ERXCollectors.toNSSet()); // Accumulate people by name into a NSDictionary NSDictionary dictionary = people.stream().collect(ERXCollectors.toNSDictionary(Person::name, Function.identity()));
Modifier and Type | Method and Description |
---|---|
static <T> Collector<T,?,NSArray<T>> |
toNSArray()
Returns a
Collector that accumulates the input elements into a new
NSArray . |
static <T,K,U> Collector<T,?,NSDictionary<K,U>> |
toNSDictionary(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends U> valueMapper)
Returns a
Collector that accumulates the input elements grouped by
key/value into a new NSDictionary . |
static <T,K,U> Collector<T,?,NSDictionary<K,U>> |
toNSDictionary(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends U> valueMapper,
BinaryOperator<U> mergeFunction)
Returns a
Collector that accumulates the input elements grouped by
key/value into a new NSDictionary . |
static <T> Collector<T,?,NSSet<T>> |
toNSSet()
Returns a
Collector that accumulates the input elements into a new
NSSet . |
public static <T> Collector<T,?,NSArray<T>> toNSArray()
Collector
that accumulates the input elements into a new
NSArray
.T
- the type of the input elementsCollector
which collects all the input elements into a
NSArray
, in encounter orderpublic static <T> Collector<T,?,NSSet<T>> toNSSet()
Collector
that accumulates the input elements into a new
NSSet
.T
- the type of the input elementsCollector
which collects all the input elements into a
NSSet
, in encounter orderpublic static <T,K,U> Collector<T,?,NSDictionary<K,U>> toNSDictionary(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
Collector
that accumulates the input elements grouped by
key/value into a new NSDictionary
.keyMapper
- a mapping function to produce keys.valueMapper
- a mapping function to produce values.Collector
which collects elements into a
NSDictionary
whose keys and values are the result of applying
mapping functions to the input elements.public static <T,K,U> Collector<T,?,NSDictionary<K,U>> toNSDictionary(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, BinaryOperator<U> mergeFunction)
Collector
that accumulates the input elements grouped by
key/value into a new NSDictionary
.keyMapper
- a mapping function to produce keys.valueMapper
- a mapping function to produce valuesmergeFunction
- a merge function, used to resolve collisions between values
associated with the same key, as supplied to
Map.merge(Object, Object, BiFunction)
Collector
which collects elements into a
NSDictionary
whose keys are the result of applying a key
mapping function to the input elements, and whose values are the
result of applying a value mapping function to all input elements
equal to the key and combining them using the merge functionCopyright © 2002 – 2024 Project Wonder.