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

Method getPercent

core/src/processing/data/FloatList.java:816–828  ·  view source on GitHub ↗

Returns a normalized version of this array. Called getPercent() for consistency with the Dict classes. It's a getter method because it needs to return a new list (because IntList/Dict can't do percentages or normalization in place on int values).

()

Source from the content-addressed store, hash-verified

814 * can't do percentages or normalization in place on int values).
815 */
816 @SuppressWarnings("unused")
817 public FloatList getPercent() {
818 double sum = 0;
819 for (float value : array()) {
820 sum += value;
821 }
822 FloatList outgoing = new FloatList(count);
823 for (int i = 0; i < count; i++) {
824 double percent = data[i] / sum;
825 outgoing.set(i, (float) percent);
826 }
827 return outgoing;
828 }
829
830
831 @SuppressWarnings("unused")

Callers

nothing calls this directly

Calls 2

arrayMethod · 0.95
setMethod · 0.95

Tested by

no test coverage detected