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)
| 143 | * Helpful for situations like sorting and then grabbing the top 50 entries. |
| 144 | */ |
| 145 | public void resize(int length) { |
| 146 | if (length > count) { |
| 147 | throw new IllegalArgumentException("resize() can only be used to shrink the dictionary"); |
| 148 | } |
| 149 | if (length < 1) { |
| 150 | throw new IllegalArgumentException("resize(" + length + ") is too small, use 1 or higher"); |
| 151 | } |
| 152 | |
| 153 | String[] newKeys = new String[length]; |
| 154 | String[] newValues = new String[length]; |
| 155 | PApplet.arrayCopy(keys, newKeys, length); |
| 156 | PApplet.arrayCopy(values, newValues, length); |
| 157 | keys = newKeys; |
| 158 | values = newValues; |
| 159 | count = length; |
| 160 | resetIndices(); |
| 161 | } |
| 162 | |
| 163 | |
| 164 | /** |
nothing calls this directly
no test coverage detected