Advertisement
Guest User

stefan is a nigger

a guest
Sep 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. public DoubleLink SwapLinkWithNext(DoubleLink link)
  2.         {
  3.             DoubleLink next = link.Next;
  4.             if (next == null)
  5.             {
  6.                 return null;
  7.             }
  8.             DoubleLink previous = link.Previous;
  9.             DoubleLink current = link;
  10.             DoubleLink nextNext = next.Next;
  11.  
  12.             current.Next = next.Next;
  13.             current.Previous = next;
  14.  
  15.             next.Previous = previous;
  16.             next.Next = current;
  17.  
  18.             if (previous == null)
  19.             {
  20.                 First = next;
  21.             } else {
  22.                 previous.Next = next;
  23.             }
  24.             if (nextNext == null)
  25.             {
  26.                 Last = current;
  27.             } else {
  28.                 nextNext.Previous = current;
  29.             }
  30.  
  31.             return next;
  32.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement