Advertisement
k0mZ

Untitled

Mar 17th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. template <class T>
  2. void CSortList<T>::swap(Node<T>* previousA, Node<T>* a, Node<T>* previousB, Node<T>* b) {
  3. if (a == b)
  4. return;
  5.  
  6. if (a->link == b || b->link == a)
  7. {
  8. this->xchangeInfo(a, b);
  9. return;
  10. }
  11.  
  12. if (previousA == nullptr)
  13. {
  14. head = b;
  15.  
  16. }
  17. else
  18. {
  19. previousA->link = b;
  20. }
  21.  
  22. if (previousB == nullptr)
  23. {
  24. head = a;
  25.  
  26. }
  27. else
  28. {
  29. previousB->link = a;
  30.  
  31. }
  32.  
  33. Node<T>* tmp = a->link;
  34. a->link = b->link;
  35. b->link = tmp;
  36.  
  37. while (tail->link != nullptr)
  38. {
  39. tail = tail->link;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement