docs: private void add(Element element)
      {
          if (ivElements == null)
          {
              ivElements = new Element[DEFAULT_CAPACITY];
          }
          else if (ivTailIndex == ivElements.length)
          {
              // No more room at the tail of the array.  If we're completely out of
              // space (ivBaseIndex == 0), then we need a bigger array.  Otherwise,
              // determine if we can reset ivBaseIndex to 0 without needing to copy
              // more than half the elements.  If not, we allocate a new array.
              //
              // We choose to limit to half the array to avoid repeatedly copying
              // the array.  For example, if the array is full and ivBaseIndex == 0,
              // and we have a sequence of remove(0)/add(x), we do not want:
              //   - remove(0): ivBaseIndex++
              //   - add(x): copy 1..N to 0..N-1, ivBaseIndex=0, array[N] = x
              //   - remove(0): ivBaseIndex++
              //   - add(x): copy 1..N to 0..N-1, ivBaseIndex=0, array[N] = x
              //   - ...etc.
  
              int size = size();
              int halfCapacity = ivElements.length >> 1;
              if (ivHeadIndex > halfCapacity)
              {
                  // Less than half of the array is full.  Rather than creating a new
                  // array, just copy all the elements to the front.
                  System.arraycopy(ivElements, ivHeadIndex, ivElements, 0, size);
                  Arrays.fill(ivElements, ivHeadIndex, ivElements.length, null);
              }
              else
              {
                  // Either we're completely out of space (ivBaseIndex == 0), or it
                  // would be wasteful to continuously copy over half the elements.
                  // Grow the array by half its current size.
                  Element[] newElements = new Element[ivElements.length + halfCapacity];
                  System.arraycopy(ivElements, ivHeadIndex, newElements, 0, size);
                  ivElements = newElements;
              }
  
              ivHeadIndex = 0;
              ivTailIndex = size;
          }
  
          ivElements[ivTailIndex++] = element;
      }