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

Method resize

core/src/processing/data/IntDict.java:126–142  ·  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

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

Callers

nothing calls this directly

Calls 2

arrayCopyMethod · 0.95
resetIndicesMethod · 0.95

Tested by

no test coverage detected