/** * Adds a new bin to the histogram. * * @param range the data range for this bin. * @throws HistogramException if the new bin overlaps with an existing bin */ 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; }