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