@Test public void testOverlappingBinsThrowsException() { hist.addBin(Range.create(0.0, true, 0.1, true)); try { hist.addBin(Range.create(0.1, true, 0.2, true)); fail("Expected an exception"); } catch (HistogramException ex) { System.out.println(ex.getMessage()); } }
public void addBin(Range<T> range) throws HistogramException { for (Bin bin : bins) { if (range.intersects(bin.range)) { throw new HistogramException(range.toString() + " overlaps existing bin" + bin.toString()); } } bins.add(new Bin(range)); needsSort = true; }
Histogram { public void addBin(Range<T> range) throws HistogramException { for (Bin bin : bins) { if (range.intersects(bin.range)) { throw new HistogramException(range.toString() + " overlaps existing bin" + bin.toString()); } } bins.add(new Bin(range)); needsSort = true; } }
Histogram { public void addBin(Range<T> range) throws HistogramException { for (Bin bin : bins) { if (range.intersects(bin.range)) { throw new HistogramException(range.toString() + " overlaps existing bin" + bin.toString()); } } bins.add(new Bin(range)); needsSort = true; } Histogram(); }
Histogram { public void addBin(Range<T> range) throws HistogramException { for (Bin bin : bins) { if (range.intersects(bin.range)) { throw new HistogramException(range.toString() + " overlaps existing bin" + bin.toString()); } } bins.add(new Bin(range)); needsSort = true; } 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 void addBin(Range<T> range) throws HistogramException { for (Bin bin : bins) { if (range.intersects(bin.range)) { throw new HistogramException(range.toString() + " overlaps existing bin" + bin.toString()); } } bins.add(new Bin(range)); needsSort = true; } 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; }