T
- element-type that is reduced / added.public class ReductionOutcome<T> extends Object
The reduction operation takes an input list of elements, and creates an output list.
The output list contains, and combination of:
Constructor and Description |
---|
ReductionOutcome()
Create with an empty list of retained-indices.
|
ReductionOutcome(List<Integer> indicesRetained) |
ReductionOutcome(List<Integer> indicesRetained,
List<T> added) |
Modifier and Type | Method and Description |
---|---|
void |
addIndexToRetain(int index)
Adds an index to be retained after reduction.
|
void |
addNewlyAdded(T toAdd)
Adds a newly-added element, that didn't exist in the input list for reduction, but should
exist in the output list.
|
List<T> |
listAfter(List<T> input)
Generates a list of elements that exist after the reduction.
|
<S> ReductionOutcome<S> |
map(java.util.function.UnaryOperator<Integer> mapIndex,
java.util.function.Function<T,S> mapAdded)
Creates a new
ReductionOutcome where both the retained-indices and the newly-added
elements may be mapped. |
int |
sizeAfter()
The total number of elements after reduction.
|
public ReductionOutcome()
public void addIndexToRetain(int index)
index
- an index identifying an element in the input list for reduction, that should be
retained in the output.public void addNewlyAdded(T toAdd)
toAdd
- the element to add.public List<T> listAfter(List<T> input)
input
- the list of elements that was passed as an input to reduce.public int sizeAfter()
public <S> ReductionOutcome<S> map(java.util.function.UnaryOperator<Integer> mapIndex, java.util.function.Function<T,S> mapAdded)
ReductionOutcome
where both the retained-indices and the newly-added
elements may be mapped.S
- the type of the newly-added elements after the mapping.mapIndex
- maps a given index in the input-list to a new index in the output-list.mapAdded
- maps a given newly-added object in the input-list to corresponding element in
the output-list.ReductionOutcome
containing the result of the mappings, as
described above.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.