@Test public void testAddValue() { hist.addBin(Range.create(0.1, true, 0.2, false)); hist.addBin(Range.create(0.2, true, 0.3, false)); hist.addBin(Range.create(0.3, true, 0.4, false)); hist.addValue(0.0); hist.addValue(0.1); hist.addValue(0.15); hist.addValue(0.2); hist.addValue(0.25); hist.addValue(0.25); hist.addValue(0.5); assertEquals(Arrays.asList(2, 3, 0), hist.getCounts()); }
public int addValue(T value) { int index = getBinForValue(value); if (index != NO_BIN) { bins.get(index).count++; } return index; }
Histogram { public int addValue(T value) { int index = getBinForValue(value); if (index != NO_BIN) { bins.get(index).count++; } return index; } }
Histogram { public int addValue(T value) { int index = getBinForValue(value); if (index != NO_BIN) { bins.get(index).count++; } return index; } Histogram(); }
Histogram { public int addValue(T value) { int index = getBinForValue(value); if (index != NO_BIN) { bins.get(index).count++; } return index; } Histogram(); void addBin(Range<T> range); int addValue(T value); void addValues(List<T> values); int getBinForValue(T value); List<Integer> getBinForValues(List<T> values); int size(); List<Integer> getCounts(); }
Histogram { public int addValue(T value) { int index = getBinForValue(value); if (index != NO_BIN) { bins.get(index).count++; } return index; } Histogram(); void addBin(Range<T> range); int addValue(T value); void addValues(List<T> values); int getBinForValue(T value); List<Integer> getBinForValues(List<T> values); int size(); List<Integer> getCounts(); static final int NO_BIN; }