Package elemental.util

Examples of elemental.util.ArrayOfInt


  /**
   * Compute a histogram with number of finishers per bucket of time where the
   * size of the bucket is indicated by <code>seconds</code>.
   */
  private static ArrayOfInt computeHistogram(ArrayOf<Runner> runners, int seconds) {
    final ArrayOfInt hist = Collections.arrayOfInt();

    for (int i = 0, n = runners.length(); i < n; ++i) {
      int index = runners.get(i).time() / seconds;
      hist.set(index, hist.isSet(index) ? hist.get(index) + 1 : 1);
    }

    int sum = 0;
    for (int i = 0, n = hist.length(); i < n; ++i) {
      if (hist.isSet(i)) {
        sum += hist.get(i);
      }
      hist.set(i, sum);
    }

    return hist;
  }
View Full Code Here


        listener.modelDidFinishBuildingIndex(Model.this);
      }
    }, 0);

    // Compute histogram.
    final ArrayOfInt histogram = computeHistogram(runners, SECONDS_PER_HISTOGRAM_BUCKET);

    // Update fields.
    this.histogram = histogram;
  }
View Full Code Here

TOP

Related Classes of elemental.util.ArrayOfInt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.