protected void bubbleDown(int curr)
    {
        while (true) {
            int smallest = curr;
            if (left(curr) < size
                && lval(curr).compareTo(getdata(smallest)) < 0) {
                smallest = left(curr);
            }
            if (right(curr) < size
                && rval(curr).compareTo(getdata(smallest)) < 0) {
                smallest = right(curr);
            }
            if (smallest == curr) {
                return;
            }
            swap(smallest, curr);
            curr = smallest;
        }
    }