The initial state of the chain is pt -> 1 -> 2 -> 3, the nodes are represented by pt, pt.Next, pt.Next.Next and pt.Next.Next.Next.
After the swap, the chain is pt -> 2 -> 1 -> 3, and pt points to 1. We can easily update the variables, point to the new Next in one line.
Signed-off-by: Hanlin Shi shihanlin9@gmail.com
The initial state of the chain is
pt -> 1 -> 2 -> 3
, the nodes are represented bypt
,pt.Next
,pt.Next.Next
andpt.Next.Next.Next
. After the swap, the chain ispt -> 2 -> 1 -> 3
, andpt
points to1
. We can easily update the variables, point to the newNext
in one line.