/** * This file is a skeleton for your GeneralizedReduce implementation. * You can assume that each client includes a call to perf.doWork(1) for each call to the * combine() method. This abstraction assumes that each call to * combine() takes 1 unit of time, and ignores the cost all other * computations. You should aim for maximum parallelism with respect * to this abstraction. All code should include basic documentation * for each method in this class. * Takes a generic argument of the kind of object that will be reduced * * * Note: doWork will typically be in the combine method of the app * Also, this reduction should work with any T that both has * an identity and can be reduced. Don't assume that grading * will be done with SumReduction * * TODO class to be implemented by you. * Though you will need to extend this file for your homework submission, * do not alter the declarations below in any way, other than filling * in the "..." code regions. * * @author Vivek Sarkar (vsarkar@rice.edu) */ public class GeneralizedReduce { /** * The object for reducing elements */ private final GeneralizedReduceApp app; /** * Constructor for Generalized Reduce * @param app - the reduction application being * used */ public GeneralizedReduce(final GeneralizedReduceApp app) { this.app = app; } /** * Reduces an array of objects to a single value * @param inArray - an array of objects to reduce * @return the reduction of the array */ public T run(final T[] inArray) { // Perform reduction on inArray using init() and combine() methods in app, // and return result // ... return null; } // ... // Insert other helper fields and methods here }