/** * Gets the bin index for a value. The value is not added to the histogram. * * @param value the value * * @return the bin index or {@link #NO_BIN} */ public int getBinForValue(T value) { ensureBinsSorted(); return findBin(value); }
/** * Adds a list of values to the histogram. This will be faster than * adding values one at a time if the list is at least partially * sorted. * * @param values input values */ public void addValues(List<T> values) { ensureBinsSorted(); int curIndex = NO_BIN; Bin bin = null; for (T value : values) { int index = findBin(value); if (index != NO_BIN) { if (index != curIndex) { bin = bins.get(index); curIndex = index; } bin.count++ ; } } }