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

Method getPercent

core/src/processing/data/LongList.java:773–785  ·  view source on GitHub ↗

Returns a normalized version of this array. Called getPercent() for consistency with the Dict classes. It's a get 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

771 * percentages or normalization in place on int values).
772 */
773 @SuppressWarnings("unused")
774 public FloatList getPercent() {
775 double sum = 0;
776 for (int i = 0; i < count; i++) {
777 sum += data[i];
778 }
779 FloatList outgoing = new FloatList(count);
780 for (int i = 0; i < count; i++) {
781 double percent = data[i] / sum;
782 outgoing.set(i, (float) percent);
783 }
784 return outgoing;
785 }
786
787
788 @SuppressWarnings("unused")

Callers

nothing calls this directly

Calls 1

setMethod · 0.95

Tested by

no test coverage detected