/*
 * Licensed Materials - Property of Rogue Wave Software, Inc. 
 * © Copyright Rogue Wave Software, Inc. 2014, 2017 
 * © Copyright IBM Corp. 2009, 2014
 * © Copyright ILOG 1996, 2009
 * All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * The Software and Documentation were developed at private expense and
 * are "Commercial Items" as that term is defined at 48 CFR 2.101,
 * consisting of "Commercial Computer Software" and
 * "Commercial Computer Software Documentation", as such terms are
 * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
 * as applicable.
 */
package minmax;

import ilog.views.chart.data.IlvDataSet;

/**
 * A combined data set that computes the maximum value of a given category.
 */
class YMaxDataSet extends YOperatorDataSet {
  /**
   * Creates a new <code>YMaxDataSet</code> object.
   * 
   * @param name
   *          The name of this data set.
   * @param dataSets
   *          The referenced data sets.
   */
  public YMaxDataSet(String name, IlvDataSet[] dataSets) {
    super(name);
    setDataSets(dataSets);
  }

  /**
   * Return the maximum value in the specified series.
   */
  Override
  protected double getData(double[] values) {
    double max = -Double.MAX_VALUE;
    for (int i = 0; i < values.length; ++i)
      if (values[i] > max)
        max = values[i];
    return max;
  }
}