Hi
I have this insertionSort method in my class but really I don't know that if
Java Code:
end == list.getLast()
what will happen? I think it doesn't mention this situation in this part of a code that i have found it in the internet .please help me,thanks
Java Code:
    public DNode getLast() throws IllegalStateException {
        if (isEmpty()) {
            throw new IllegalStateException("the list is empty");
        }
        return trailer.getPrev();
    } 

     public void insertionSort(DoublyLinkedList list) {
        if (list.size <= 1) {
            return;//L is already sorted in this case
        }
        DNode end, p, ins;
        end = list.getFirst();
        while (end != list.getLast()) {
            p = end.getNext();
            list.remove(p);
            ins = end;
            while (list.hasPrev(ins) &&      ins.getElement().compareTo(p.getElement()) > 0) {
                ins = ins.getPrev();
                list.addAfter(ins, p);
                if (ins == end) {
                    end = end.getNext();
                }


            }

        }
    }