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