//  stack : headerfile for the free standard C++ library
//  
//  Copyright (C) 1999 by the free standard C++ Library Team
//                        see AUTHORS for more details
//
//  Homepage : http://www.inf.fu-berlin.de/~mkrueger/fscl/
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Library General Public
//  License as published by the Free Software Foundation; either	
//  version 2 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Library General Public License for more details.
//  You should have received a copy of the GNU Library General Public
//  License along with this library; if not, write to the Free
//  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//  version : 0.1 last modified : 17.09.99


#ifndef __CPP_STACK
#define __CPP_STACK

#include<cstddef>
#include<new>

#include<vector>

namespace std {
	
	template <class T, class Container = vector<T> > 
	class stack
	{
		public:
			typedef typename Container::value_type value_type;
			typedef typename Container::size_type  size_type;
			typedef Container                      container_type;
		public:

			explicit stack(const Container &con = Container())
			: c(con)
			{
			}
			
			bool     empty() const
			{
				return c.empty();
			}

			size_type size()  const
			{
				return c.size();
			}

			value_type& top()
			{
				return c.back(); 
			}

			const value_type& top() const
			{
				return c.back(); 
			}

			void push(const value_type& x)
			{
				c.push_back(x);
			}

			// NON STANDARD : POP RETURNS POPPED VALUE 
			// STANDARD     : RETURNS VOID
			//(I find stacks more useful with this option)
			value_type pop()
			{
				value_type tmp = top();
				c.pop_back();
				return tmp;
			}
		protected:
			Container c;
    };

	template <class T, class Container>
	bool operator==(const stack<T, Container> &x, const stack<T, Container> &y)
	{
		return x.c == y.c;	
	}

	template <class T, class Container>
	bool operator< (const stack<T, Container> &x, const stack<T, Container> &y)
	{
		return x.c < y.c;
	}

	template <class T, class Container>
	bool operator!=(const stack<T, Container> &x, const stack<T, Container> &y)
	{
		return x.c != y.c;
	}

	template <class T, class Container>
	bool operator> (const stack<T, Container> &x, const stack<T, Container> &y)
	{
		return x.c > y.c;
	}

	template <class T, class Container>
	bool operator>=(const stack<T, Container> &x, const stack<T, Container> &y)
	{
		return x.c >= y.c;
	}

	template <class T, class Container>
	bool operator<=(const stack<T, Container> &x, const stack<T, Container> &y)
	{
		return x.c <= y.c;
	}
}
#endif
