Guest User

Untitled

a guest
Sep 13th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. template<typename T> class stupid_stack {
  2. std::stack<T> stuff;
  3. std::stack<T> max;
  4. public:
  5. void push(const T& t) {
  6. stuff.push(t);
  7. max.push(std::max(t, max.top()));
  8. }
  9. void pop() {
  10. stuff.pop();
  11. max.pop();
  12. }
  13. T max() {
  14. return max.top();
  15. }
  16. T top() {
  17. return stuff.top();
  18. }
  19. };
Advertisement
Add Comment
Please, Sign In to add comment