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).
()
| 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") |