    @SuppressWarnings("unchecked")
    private E removeAt(int i) {
        modCount++;
        int s = --size;
        if (s == i) {
            queue[i] = null;
        } else {
            E moved = (E) queue[s];
            queue[s] = null;
            siftDown(i, moved);
            if (queue[i] == moved) {
                siftUp(i, moved);
                if (queue[i] != moved) {
                    return moved;
                }