Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class T>
- class dll_t {
- private:
- dll_node_t<T>* head_;
- dll_node_t<T>* tail_;
- int sz_;
- public:
- dll_t(void);
- ~dll_t(void);
- void insert_tail(dll_node_t<T>*);
- void insert_head(dll_node_t<T>*);
- dll_node_t<T>* extract_tail(void);
- dll_node_t<T>* extract_head(void);
- dll_node_t<T>* get_tail(void) const;
- dll_node_t<T>* get_head(void) const;
- bool empty(void);
- void remove(dll_node_t<T>*);
- ostream& write(ostream& os) const;
- void select(dll_t<dll_node_t<T>*>& L, const T& x);
- private:
- bool igual(const T& a, const T&b);
- };
- template <class T>
- class dll_node_t {
- private:
- dll_node_t<T>* next_;
- dll_node_t<T>* prev_;
- T data_;
- public:
- dll_node_t();
- dll_node_t(const T& data);
- virtual ~dll_node_t(void);
- void set_next(dll_node_t<T>*);
- void set_prev(dll_node_t<T>*);
- dll_node_t<T>* get_next(void) const;
- dll_node_t<T>* get_prev(void) const;
- void set_data(const T& data);
- T get_data(void) const;
- ostream& write(ostream& os) const;
- };
- template<class T>
- ostream& dll_t<T>:: write_reverse(dll_node_t<T>* n, ostream& os) const {
- assert(!empty());
- while(n!=NULL){
- n=n->get_data();
- n.write(os);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement