MCPcopy
hub / github.com/libgdx/libgdx / ensureCapacity

Method ensureCapacity

gdx/src/com/badlogic/gdx/utils/Array.java:469–474  ·  view source on GitHub ↗

Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many items to avoid multiple backing array resizes. @return #items

(int additionalCapacity)

Source from the content-addressed store, hash-verified

467 * items to avoid multiple backing array resizes.
468 * @return {@link #items} */
469 public T[] ensureCapacity (int additionalCapacity) {
470 if (additionalCapacity < 0) throw new IllegalArgumentException("additionalCapacity must be >= 0: " + additionalCapacity);
471 int sizeNeeded = size + additionalCapacity;
472 if (sizeNeeded > items.length) resize(Math.max(Math.max(8, sizeNeeded), (int)(size * 1.75f)));
473 return items;
474 }
475
476 /** Sets the array size, leaving any values beyond the current size null.
477 * @return {@link #items} */

Callers

nothing calls this directly

Calls 2

resizeMethod · 0.95
maxMethod · 0.45

Tested by

no test coverage detected