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