I just looked through you code a bit and it all has to do with your swap function. Take a deeper look at this section of the code and debug it to see if you are getting expected values.
assert currentX != null;
SingleSwap temp = currentX.next; //swap the x and y pointers
assert currentY != null;
currentX.next = currentY.next;
currentY.next = temp;
I am doing something similar to this also through school. Code look clean, just try to figure that pot out and you should be golden. I will look at it some more when I get in from work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…