Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. template <class T>
  2. class dll_t {
  3. private:
  4. dll_node_t<T>* head_;
  5. dll_node_t<T>* tail_;
  6. int sz_;
  7. public:
  8. dll_t(void);
  9. ~dll_t(void);
  10. void insert_tail(dll_node_t<T>*);
  11. void insert_head(dll_node_t<T>*);
  12. dll_node_t<T>* extract_tail(void);
  13. dll_node_t<T>* extract_head(void);
  14. dll_node_t<T>* get_tail(void) const;
  15. dll_node_t<T>* get_head(void) const;
  16. bool empty(void);
  17. void remove(dll_node_t<T>*);
  18. ostream& write(ostream& os) const;
  19. void select(dll_t<dll_node_t<T>*>& L, const T& x);
  20. private:
  21. bool igual(const T& a, const T&b);
  22. };
  23.  
  24. template <class T>
  25. class dll_node_t {
  26. private:
  27. dll_node_t<T>* next_;
  28. dll_node_t<T>* prev_;
  29. T data_;
  30. public:
  31. dll_node_t();
  32. dll_node_t(const T& data);
  33. virtual ~dll_node_t(void);
  34. void set_next(dll_node_t<T>*);
  35. void set_prev(dll_node_t<T>*);
  36. dll_node_t<T>* get_next(void) const;
  37. dll_node_t<T>* get_prev(void) const;
  38. void set_data(const T& data);
  39. T get_data(void) const;
  40. ostream& write(ostream& os) const;
  41. };
  42.  
  43. template<class T>
  44.  
  45. ostream& dll_t<T>:: write_reverse(dll_node_t<T>* n, ostream& os) const {
  46. assert(!empty());
  47. while(n!=NULL){
  48. n=n->get_data();
  49. n.write(os);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement