Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. void List::operator+=(int key)
  2. {
  3.     this->addToEnd(key);
  4. }
  5.  
  6. void List::operator+=(ListElement& element)
  7. {
  8.     this->addToEnd(ListElement * element);
  9. }
  10.  
  11. void List::operator+=(ListElement* element)
  12. {
  13.     this->addToEnd(ListElement *element);
  14. }
  15.  
  16. void List::operator-=(int key)
  17. {
  18.     this->removeKey(key);
  19. }
  20.  
  21. void List::operator-=(ListElement& element)
  22. {
  23.     this->removeKey(element->getKey());
  24. }
  25.  
  26. void List::operator-=(ListElement* element)
  27. {
  28.     this->removeKey(element->getKey());
  29. }
  30.  
  31. bool List::operator== (List& otherList)
  32. {
  33.     bool control;
  34.  
  35.     if (sizeof(this) == sizeof(otherList))
  36.     {
  37.         while (this->next != NULL)
  38.         {
  39.             control = 0;
  40.  
  41.             while (otherList->next != NULL)
  42.             {
  43.                 if (this->getKey() == otherList->getKey())
  44.                 {
  45.                     control = 1;
  46.                 }
  47.                 otherList = otherList->next;
  48.             }
  49.  
  50.             if (!control)
  51.             {
  52.                 return 0;
  53.             }
  54.             this = this->next;
  55.         }
  56.  
  57.         return 1;
  58.     }
  59.     else
  60.     {
  61.         return 0;
  62.     }
  63. }
  64.  
  65. bool List::operator!= (List& otherList)
  66. {
  67.     bool control;
  68.  
  69.     if (sizeof(this) != sizeof(otherList))
  70.     {
  71.         while (this->next != NULL)
  72.         {
  73.             control = 1;
  74.  
  75.             while (otherList->next != NULL)
  76.             {
  77.                 if (this->getKey() == otherList->getKey())
  78.                 {
  79.                     control = 0;
  80.                 }
  81.                 otherList = otherList->next;
  82.             }
  83.  
  84.             if (!control)
  85.             {
  86.                 return 0;
  87.             }
  88.             this = this->next;
  89.         }
  90.  
  91.         return 1;
  92.     }
  93.     else
  94.     {
  95.         return 0;
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement