Resize the internal data, this can only be used to shrink the list. Helpful for situations like sorting and then grabbing the top 50 entries.
(int length)
| 121 | * Helpful for situations like sorting and then grabbing the top 50 entries. |
| 122 | */ |
| 123 | public void resize(int length) { |
| 124 | if (length == count) return; |
| 125 | |
| 126 | if (length > count) { |
| 127 | throw new IllegalArgumentException("resize() can only be used to shrink the dictionary"); |
| 128 | } |
| 129 | if (length < 1) { |
| 130 | throw new IllegalArgumentException("resize(" + length + ") is too small, use 1 or higher"); |
| 131 | } |
| 132 | |
| 133 | String[] newKeys = new String[length]; |
| 134 | float[] newValues = new float[length]; |
| 135 | PApplet.arrayCopy(keys, newKeys, length); |
| 136 | PApplet.arrayCopy(values, newValues, length); |
| 137 | keys = newKeys; |
| 138 | values = newValues; |
| 139 | count = length; |
| 140 | resetIndices(); |
| 141 | } |
| 142 | |
| 143 | |
| 144 | /** |
nothing calls this directly
no test coverage detected