Hi, all. I'm implementing a little linked list that selection-sorts itself. 
Basically, the sort code is:
swap this element with the minimum element in the list.
sort the rest of the list.

Obviously, one part of this is swapping elements. It seemed easiest to swap the 
contents of two nodes, rather
than messing with rearranging the elements.
Now, that description of swap sounds impure, right? But this compiles:
private pure void swap(SortableListNode other){ //SortableListNode is a class.
        T temp = this.datum;
        this.datum = other.datum;
        other.datum = temp;
}
Am I missing the point of pure somehow? Am I going crazy? (The sort does work, 
so the elements are being
mutated.)
Thanks,
Charles.

Reply via email to