Class Groups<G,K,V>
java.lang.Object
org.moeaframework.analysis.stream.ImmutablePartition<G,Partition<K,V>>
org.moeaframework.analysis.stream.Groups<G,K,V>
- Type Parameters:
G
- the type of the grouping keyK
- the original key typeV
- the type of each value
- All Implemented Interfaces:
Partition<G,
,Partition<K, V>> Displayable
,Formattable<org.apache.commons.lang3.tuple.Pair<G,
Partition<K, V>>>
Groups items together using a "grouping key". This grouping key can be the same as, or different from, the key
found in the
Partition
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the group with the given grouping key.groupEachBy
(Function<K, R> grouping) Equivalent to callingPartition.groupBy(Function)
on each group, keeping the grouping intact.Equivalent to callingPartition.map(Function)
on each group, keeping the grouping intact.measureEach
(Function<Stream<V>, R> measure) Equivalent to callingPartition.measure(Function)
on each group, keeping the grouping intact.reduceEach
(BinaryOperator<V> op) Equivalent to callingPartition.reduce(BinaryOperator)
on each group, keeping the grouping intact.reduceEach
(V identity, BinaryOperator<V> op) Equivalent to callingPartition.reduce(Object, BinaryOperator)
on each group, keeping the grouping intact.sorted()
Sorts the partition using the natural ordering of keys.sorted
(Comparator<G> comparator) Sorts the partition based on their keys.Methods inherited from class org.moeaframework.analysis.stream.ImmutablePartition
size, stream
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.util.format.Displayable
display
-
Constructor Details
-
Groups
Constructs a new grouping with the given content.- Parameters:
content
- the content of this grouping
-
Groups
Constructs a new grouping with the given content.- Parameters:
stream
- a stream of the content
-
-
Method Details
-
get
Returns the group with the given grouping key.- Parameters:
key
- the grouping key- Returns:
- the contents of the group
-
sorted
Description copied from interface:Partition
Sorts the partition using the natural ordering of keys.- Returns:
- the sorted stream
-
sorted
Description copied from interface:Partition
Sorts the partition based on their keys.- Parameters:
comparator
- the comparator used to sort keys- Returns:
- the sorted partition
-
mapEach
Equivalent to callingPartition.map(Function)
on each group, keeping the grouping intact.- Type Parameters:
R
- the result type- Parameters:
map
- the map function- Returns:
- the groups after applying the map function
-
measureEach
Equivalent to callingPartition.measure(Function)
on each group, keeping the grouping intact.- Type Parameters:
R
- the result type- Parameters:
measure
- the measurement function- Returns:
- the groups after applying the measurement function
-
reduceEach
Equivalent to callingPartition.reduce(BinaryOperator)
on each group, keeping the grouping intact.- Parameters:
op
- the reduction operator- Returns:
- the groups after applying the reduction operator
-
reduceEach
Equivalent to callingPartition.reduce(Object, BinaryOperator)
on each group, keeping the grouping intact.- Parameters:
identity
- the initial value supplied to the reduction operatorop
- the reduction operator- Returns:
- the groups after applying the reduction operator
-
groupEachBy
Equivalent to callingPartition.groupBy(Function)
on each group, keeping the grouping intact.- Type Parameters:
R
- the return type of the grouping function- Parameters:
grouping
- the grouping function- Returns:
- the groups after applying the grouping function
-