MCPcopy Create free account
hub / github.com/benfry/processing4 / resize

Method resize

core/src/processing/data/FloatDict.java:128–146  ·  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

126 * Helpful for situations like sorting and then grabbing the top 50 entries.
127 */
128 public void resize(int length) {
129 if (length == count) return;
130
131 if (length > count) {
132 throw new IllegalArgumentException("resize() can only be used to shrink the dictionary");
133 }
134 if (length < 1) {
135 throw new IllegalArgumentException("resize(" + length + ") is too small, use 1 or higher");
136 }
137
138 String[] newKeys = new String[length];
139 float[] newValues = new float[length];
140 PApplet.arrayCopy(keys, newKeys, length);
141 PApplet.arrayCopy(values, newValues, length);
142 keys = newKeys;
143 values = newValues;
144 count = length;
145 resetIndices();
146 }
147
148
149 /**

Callers

nothing calls this directly

Calls 2

arrayCopyMethod · 0.95
resetIndicesMethod · 0.95

Tested by

no test coverage detected