Data Structures, Algorithms, & Applications in Java
Chapter 5, Exercise 5

The method dataStructures.ArrayLinearListWithTrimToSize.trimToSize is given below.
/** make element.length = size */
public void trimToSize()
   {element = ChangeArrayLength.changeLength1D(element, size, size);}



The complexity is O(size) because it takes this much time to create the new array and copy the elements over.