MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / append

Method append

src/org/opensourcephysics/display/Histogram.java:282–298  ·  view source on GitHub ↗

Append a value with number of occurrences to the Histogram. @param value @param numberOfoccurrences

(double value, double numberOfoccurrences)

Source from the content-addressed store, hash-verified

280 * @param numberOfoccurrences
281 */
282 public synchronized void append(double value, double numberOfoccurrences) {
283 sum += numberOfoccurrences;
284 int binNumber = hashCode(value);
285 // Determine if there have previously been any occurrences for this bin
286 Double occurrences = bins.get(Integer.valueOf(binNumber));
287 if (occurrences == null) { // first occurence for this bin
288 bins.put(Integer.valueOf(binNumber), new Double(numberOfoccurrences));
289 } else {
290 // need to put Objects in HashMap, but can only add doubles
291 numberOfoccurrences += occurrences.doubleValue(); // increase occurrences for bin by numberOfoccurrences
292 bins.put(Integer.valueOf(binNumber), new Double(numberOfoccurrences));
293 }
294 ymax = Math.max(numberOfoccurrences, ymax);
295 xmin = Math.min(binNumber * binWidth + binOffset, xmin);
296 xmax = Math.max(binNumber * binWidth + binWidth + binOffset, xmax);
297 dataChanged = true;
298 }
299
300 /**
301 * Appends a value with 1 occurence.

Callers 1

loadObjectMethod · 0.95

Calls 11

hashCodeMethod · 0.95
doubleValueMethod · 0.80
maxMethod · 0.80
minMethod · 0.80
lengthMethod · 0.80
parseDoubleMethod · 0.80
getMethod · 0.65
equalsMethod · 0.65
closeMethod · 0.65
putMethod · 0.45
trimMethod · 0.45

Tested by

no test coverage detected