code: private void removeAt(int i) {
          Object[] array = queue;
          int n = size - 1;
          if (n == i) // removed last element
              array[i] = null;
          else {
              E moved = (E) array[n];
              array[n] = null;
              Comparator<? super E> cmp = comparator;
              if (cmp == null)
                  siftDownComparable(i, moved, array, n);
              else
                  siftDownUsingComparator(i, moved, array, n, cmp);
              if (array[i] == moved) {
                  if (cmp == null)
                      siftUpComparable(i, moved, array);
                  else
                      siftUpUsingComparator(i, moved, array, cmp);
              }
          }
          size = n;
      }
docs: Removes the ith element from queue.