MCPcopy Index your code
hub / github.com/benfry/processing4 / getPercent

Method getPercent

core/src/processing/data/LongDict.java:748–756  ·  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

746 * @return an IntDict with the original keys, mapped to their pct of the total
747 */
748 public FloatDict getPercent() {
749 double sum = sum(); // a little more accuracy
750 FloatDict outgoing = new FloatDict();
751 for (int i = 0; i < size(); i++) {
752 double percent = value(i) / sum;
753 outgoing.set(key(i), (float) percent);
754 }
755 return outgoing;
756 }
757
758
759 /** 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