#ifndef STRUCTS_DLLIST_H #define STRUCTS_DLLIST_H template class dllist { public: class node { public: node *next; node *prev; data d; node(node *next, node *prev, data d) : next(next), prev(prev), d(d) {} }; node *first; dllist() : first(0) {} void add_front(data d) { node *const n = new node(first, 0, d); if (first) first->prev = n; first = n; } //return previous, or zero if this is the first node *remove_in_place(node *n) { if (n == first) first = n->next; if (n->next) n->next->prev = n->prev; if (n->prev) n->prev->next = n->next; delete n; return n->prev; } }; #endif