code: private void remove(int listIndex)
      {
          if (listIndex == 0)
          {
              // Trivially remove from head.
              ivElements[ivHeadIndex++] = null;
          }
          else if (listIndex == ivTailIndex - 1)
          {
              // Trivially remove from tail.
              ivElements[--ivTailIndex] = null;
          }
          else
          {
              // Determine whether shifting the head or the tail requires the lower
              // number of element copies.
  
              int size = size();
              int halfSize = size >> 1;
              if (listIndex < halfSize)
              {
                  // The index is less than half.  Shift the elements at the head of
                  // the array up one index to cover the removed element.
                  System.arraycopy(ivElements, ivHeadIndex, ivElements, ivHeadIndex + 1, listIndex);
                  ivElements[ivHeadIndex++] = null;
              }
              else
              {
                  // The index is more than half.  Shift the elements at the tail of
                  // the array down one index to cover the removed element.
                  int arrayIndex = ivHeadIndex + listIndex;
                  System.arraycopy(ivElements, arrayIndex + 1, ivElements, arrayIndex, size - listIndex - 1);
                  ivElements[--ivTailIndex] = null;
              }
          }
  
          if (isEmpty())
          {
              // Reset ivHeadIndex to 0 to avoid element copies in add().
              ivHeadIndex = 0;
              ivTailIndex = 0;
          }
      }
docs: Removes the element at the specified index. The index must be greater or
  equal to 0 and less than the size; otherwise, the behavior is undefined.
  
  @param listIndex the index of the element to remove