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

Method getPercent

core/src/processing/data/FloatDict.java:819–827  ·  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 a FloatDict with the original keys, mapped to their pct of the total

()

Source from the content-addressed store, hash-verified

817 * @return a FloatDict with the original keys, mapped to their pct of the total
818 */
819 public FloatDict getPercent() {
820 double sum = sum();
821 FloatDict outgoing = new FloatDict();
822 for (int i = 0; i < size(); i++) {
823 double percent = value(i) / sum;
824 outgoing.set(key(i), (float) percent);
825 }
826 return outgoing;
827 }
828
829
830 /** 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