Advertisement
Auios

Untitled

Dec 9th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. iterator operator++(int)
  2.         {
  3.             iterator old(this->current, this->tree);
  4.             if (this->current->rth)
  5.                 this->current = this->current->right;
  6.             else
  7.             {
  8.                 this->current = this->current->right;
  9.                 while (!this->current->lth)
  10.                     this->current = this->current->left;
  11.             }
  12.             return old;
  13.         }
  14.         iterator operator--(int)
  15.         {
  16.             iterator old(this->current, this->tree);
  17.             if (!this->current)
  18.             {
  19.                 this->current = this->tree->root;
  20.                 while (!this->current->rth)
  21.                     this->current = this->current->right;
  22.             }
  23.             else if (this->current->lth)
  24.                 this->current = this->current->left;
  25.             else
  26.             {
  27.                 this->current = this->current->left;
  28.                 while (!this->current->rth)
  29.                     this->current = this->current->right;
  30.             }
  31.             return old;
  32.         }
  33.         iterator operator++()
  34.         {
  35.             if (this->current->rth)
  36.                 this->current = this->current->right;
  37.             else
  38.             {
  39.                 this->current = this->current->right;
  40.                 while (!this->current->lth)
  41.                     this->current = this->current->left;
  42.             }
  43.             return *this;
  44.         }
  45.         iterator operator--()
  46.         {
  47.             if (!this->current)
  48.             {
  49.                 this->current = this->tree->root;
  50.                 while (!this->current->rth)
  51.                     this->current = this->current->right;
  52.             }
  53.             else if (this->current->lth)
  54.                 this->current = this->current->left;
  55.             else
  56.             {
  57.                 this->current = this->current->left;
  58.                 while (!this->current->rth)
  59.                     this->current = this->current->right;
  60.             }
  61.             return *this;
  62.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement