code: @Override
    public void ensureCapacity(int expectedElements) {
      final int bufferLen = (buffer == null ? 0 : buffer.length);
      if (expectedElements > bufferLen) {
        ensureBufferSpace(expectedElements - size());
      }
    }
docs: Ensure this container can hold at least the given number of elements
  without resizing its buffers.
  
  @param expectedElements
  The total number of elements, inclusive.