MCPcopy Index your code
hub / github.com/processing/processing / resize

Method resize

core/src/processing/data/DoubleDict.java:138–156  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 /**

Callers

nothing calls this directly

Calls 2

arrayCopyMethod · 0.95
resetIndicesMethod · 0.95

Tested by

no test coverage detected