/** * Adds a bin to the dataset. An exception is thrown if the bin overlaps * with any existing bin in the dataset. * * @param bin the bin ({@code null} not permitted). * * @see #removeAllBins() */ public void addBin(SimpleHistogramBin bin) { // check that the new bin doesn't overlap with any existing bin Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin existingBin = (SimpleHistogramBin) iterator.next(); if (bin.overlapsWith(existingBin)) { throw new RuntimeException("Overlapping bin"); } } this.bins.add(bin); Collections.sort(this.bins); }
/** * Adds a bin to the dataset. An exception is thrown if the bin overlaps * with any existing bin in the dataset. * * @param bin the bin (<code>null</code> not permitted). * * @see #removeAllBins() */ public void addBin(SimpleHistogramBin bin) { // check that the new bin doesn't overlap with any existing bin Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin existingBin = (SimpleHistogramBin) iterator.next(); if (bin.overlapsWith(existingBin)) { throw new RuntimeException("Overlapping bin"); } } this.bins.add(bin); Collections.sort(this.bins); }