org.kernelab.basis.IndexedReducer Maven / Gradle / Ivy
package org.kernelab.basis;
import java.io.Serializable;
/**
* The Reducer interface is applied to the operation of reducing an Iterable
* object.
*
* @author Dilly King
*
* @param
* The generic type of the elements to be reduced in the Iterable
* object.
* @param
* The generic type of the reduce result.
*/
public interface IndexedReducer extends Serializable
{
/**
* To reduce the element in a certain Iterable object into the reduction
* result.
*
* @param result
* A former result of reduction. Attention that the result might
* be null sometime in the reduce operation.
* @param element
* An element in a certain Iterable object.
* @param index
* The index (ZERO based) of the element in the Iterable object.
* @return The result of is reduce operation.
* @throws Terminator
* to terminate the reduction procedure.
* {@link Terminator#SIGNAL} is recommended.
* @see Tools#reduce(Iterable, IndexedReducer)
*/
public R reduce(R result, E element, int index);
}