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