MCPcopy Create free account
hub / github.com/benfry/processing4 / getPercent

Method getPercent

core/src/processing/data/IntDict.java:767–775  ·  view source on GitHub ↗

Sum all of the values in this dictionary, then return a new FloatDict of each key, divided by the total sum. The total for all values will be ~1.0. @return an IntDict with the original keys, mapped to their pct of the total

()

Source from the content-addressed store, hash-verified

765 * @return an IntDict with the original keys, mapped to their pct of the total
766 */
767 public FloatDict getPercent() {
768 double sum = sum(); // a little more accuracy
769 FloatDict outgoing = new FloatDict();
770 for (int i = 0; i < size(); i++) {
771 double percent = value(i) / sum;
772 outgoing.set(key(i), (float) percent);
773 }
774 return outgoing;
775 }
776
777
778 /** Returns a duplicate copy of this object. */

Callers

nothing calls this directly

Calls 5

sumMethod · 0.95
sizeMethod · 0.95
valueMethod · 0.95
setMethod · 0.95
keyMethod · 0.95

Tested by

no test coverage detected