code: public double[] getTrimmedInternalArray() {
          if (internalArray.length == lastIndex + 1) {
              return internalArray;
          }
          double[] newArray = new double[lastIndex + 1];
          System.arraycopy(internalArray, 0, newArray, 0, newArray.length);
          return newArray;
      }
docs: Get a trimmed version of the array, i.e. without ending unset positions.
  
  @return the trimmed array.