Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #ifndef DOUBLYLIST_H
  2. #define DOUBLYLIST_H
  3.  
  4. #include <string>
  5. #include <iostream>
  6.  
  7. class Node
  8. {
  9. public:
  10. Node() : data(0), prev(nullptr), next(nullptr) {}
  11. Node(int newData, Node *newPrev, Node *newNext)
  12. : data(newData), prev(newPrev), next(newNext) {}
  13. int getData() const { return data; }
  14. Node *getPrev() const { return prev; }
  15. Node *getNext() const { return next; }
  16. void setData(int newData) { data = newData; }
  17. void setPrev(Node *newPrev) { prev = newPrev; }
  18. void setNext(Node *newNext) { next = newNext; }
  19. ~Node() {}
  20. private:
  21. int data;
  22. Node *prev;
  23. Node *next;
  24. };
  25.  
  26.  
  27. class DoublyList
  28. {
  29. public:
  30. DoublyList();
  31.  
  32. void insertBack(int newData);
  33.  
  34. bool isEmpty() const;
  35.  
  36. void destroyList();
  37. ~DoublyList();
  38.  
  39. /********************************************************
  40. Functions to implement
  41. *********************************************************/
  42.  
  43. // Declaration function print
  44. void print();
  45.  
  46. // Declaration function reversePrint
  47. void reversePrint();
  48.  
  49. // Declaration function front
  50. int front() const;
  51.  
  52. // Declaration function back
  53. int back();
  54.  
  55. // Declaration function transferList
  56. void transferList(DoublyList list2);
  57.  
  58. private:
  59. Node *first; // pointer to the first node on the list
  60. Node *last; // pointer to the last node on the list
  61. int count; // number of nodes in the list
  62. };
  63.  
  64. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement