mramine364

LinkedList.h

Sep 4th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. class LinkedList
  6. {
  7.     static struct node
  8.     {
  9.         int x;
  10.         node* next;
  11.         node* prev;
  12.     };
  13.     node* start;
  14.     node* end;
  15.     int size;
  16.     node* _sort(node* r, int n);
  17.     static void _swap(node* a, node* b){
  18.         int t = a->x;
  19.         a->x = b->x;
  20.         b->x = t;
  21.     }
  22.    
  23. public:
  24.  
  25.     LinkedList();
  26.     ~LinkedList();
  27.  
  28.     friend ostream& operator<<(ostream& out, const LinkedList& l);
  29.  
  30.     int push(int x);
  31.     int pop();
  32.     int unshift(int x);
  33.     int shift();
  34.  
  35.     int find(int x);
  36.     LinkedList* copy(int s, int e);
  37.     LinkedList* splice(int s, int e);
  38.  
  39.     void sort(){
  40.         start = _sort(start, size);
  41.     }
  42. };
Advertisement
Add Comment
Please, Sign In to add comment