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).
()
| 790 | * percentages or normalization in place on int values). |
| 791 | */ |
| 792 | @SuppressWarnings("unused") |
| 793 | public FloatList getPercent() { |
| 794 | double sum = 0; |
| 795 | for (float value : array()) { |
| 796 | sum += value; |
| 797 | } |
| 798 | FloatList outgoing = new FloatList(count); |
| 799 | for (int i = 0; i < count; i++) { |
| 800 | double percent = data[i] / sum; |
| 801 | outgoing.set(i, (float) percent); |
| 802 | } |
| 803 | return outgoing; |
| 804 | } |
| 805 | |
| 806 | |
| 807 | @SuppressWarnings("unused") |