Advertisement
deushiro

Untitled

Nov 4th, 2020 (edited)
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <cstddef>
  4.  
  5. #ifndef LIST_H
  6. #define LIST_H
  7.  
  8. namespace task {
  9.  
  10.     class list {
  11.  
  12.     public:
  13.  
  14.         list();
  15.         list(size_t count, const int &value = int());
  16.         list(const list& other);
  17.  
  18.         ~list();
  19.         list &operator=(const list &other);
  20.         bool operator==(const list &other);
  21.  
  22.  
  23.         int &front();
  24.         const int &front() const;
  25.  
  26.         int &back();
  27.         const int &back() const;
  28.  
  29.  
  30.         bool empty() const;
  31.         size_t size() const;
  32.         void clear();
  33.  
  34.  
  35.         void push_back(const int &value);
  36.         void pop_back();
  37.         void push_front(const int &value);
  38.         void pop_front();
  39.         void resize(size_t count);
  40.         void swap(list &other);
  41.  
  42.  
  43.         void remove(const int &value);
  44.         void unique();
  45.         void sort();
  46.  
  47.  
  48.     private:
  49.         class Node;
  50.  
  51.         static Node *ListSort(Node *head_, Node *tail);
  52.  
  53.         class Node {
  54.         public:
  55.             Node *pNext;
  56.             Node *pPrev;
  57.             int data;
  58.  
  59.             Node(int data = int(), Node *pNext = nullptr, Node *pPrev = nullptr) {
  60.                 this->data = data;
  61.                 this->pNext = pNext;
  62.                 this->pPrev = pPrev;
  63.             }
  64.         };
  65.  
  66.         int size_;
  67.         Node *head;
  68.         Node *tail;
  69.         void QuickSort(Node*, Node*);
  70.         Node* Partition(Node*, Node*);
  71.  
  72.  
  73.     };
  74.  
  75. }  // namespace task
  76.  
  77. #endif // LIST_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement