@SuppressWarnings("unchecked")
  public void trim(final int n) {
    // TODO: use Arrays.trim() and preserve type only if necessary
    if (n >= a.length || size == a.length) {
      return;
    }
    final K[] t = (K[]) new Object[Math.max(n, size)];
    System.arraycopy(a, 0, t, 0, size);
    a = t;
    assert !ASSERTS || size <= a.length;
  }
Trims the backing array if it is too large.

If the current array length is smaller than or equal to <code>n</code>, this method does
nothing. Otherwise, it trims the array length to the maximum between <code>n</code> and
{@link #size()}.

<P>
This method is useful when reusing lists. {@linkplain #clear() Clearing a list} leaves the
array length untouched. If you are reusing a list many times, you can call this method with a
typical size to avoid keeping around a very large array just because of a few large transient
lists.

@param n the threshold for the trimming.
geode-core/src/main/java/org/apache/geode/internal/cache/IdentityArrayList.java