// // Adaptor class providing for a single type that can act as both // a stack and a queue // File: BinSearchTree/queStack.h // // Examples: stack_queue > // stack_queue > doesn't work under gcc 2.7.2 // // ------------------------------------------------------------- #ifndef STACK_QUEUE_H #define STACK_QUEUE_H #include #include // ------------------------------------------------------------- template class stack_queue { public: typedef Container::value_type value_type; typedef Container::size_type size_type; protected: Container c; public: void push (const value_type& x) {c.push_back(x);} // insert at the beginning void append (const value_type& x) {c.push_front(x);}// append at the end of list value_type pop (void) // remove first element { value_type x; x = c.back(); c.pop_back(); return x; } bool isEmpty (void) { return c.empty() ; } void makeEmpty (void) { c.erase(c.begin(), c.end()); } }; // ------------------------------------------------------------- #endif