/*  Metrowerks Standard Library  Version 4.0  1998 August 10  */

/*  $Date: 1998/12/04 23:58:23 $ 
 *  $Revision: 1.2 $ 
 *  $NoKeywords: $ 
 *
 *		Portions Copyright  1995-1998 Metrowerks, Inc.
 *		All rights reserved.
 */

/**
 **  stack
 **/

#ifndef _STACK
#define _STACK

#include <mcompile.h>
#include <deque>

#ifndef RC_INVOKED

#pragma options align=native
#if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
	#pragma import on
#endif

#ifdef MSIPL_USING_NAMESPACE
	namespace std {
#endif

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

	explicit stack(const Container& x = Container()) : c(x) {}

	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); }
	void pop()                          { c.pop_back(); }
protected:
	Container c;

	friend bool operator== <T, Container>(const stack<T, Container>& x, const stack<T, Container>& y);
	friend bool operator!= <T, Container>(const stack<T, Container>& x, const stack<T, Container>& y);
	friend bool operator<  <T, Container>(const stack<T, Container>& x, const stack<T, Container>& y);
	friend bool operator<= <T, Container>(const stack<T, Container>& x, const stack<T, Container>& y);
	friend bool operator>  <T, Container>(const stack<T, Container>& x, const stack<T, Container>& y);
	friend bool operator>= <T, Container>(const stack<T, Container>& x, const stack<T, Container>& y);
};

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

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

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

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

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

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

#ifdef MSIPL_USING_NAMESPACE
	} // namespace std
#endif

#if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
	#pragma import reset
#endif
#pragma options align=reset

#endif // RC_INVOKED

#endif // _STACK

// hh 971220 fixed MOD_INCLUDE
// hh 971223 Changed filename from stack.h to stack
// hh 971223 added alignment wrapper
// hh 971223 Made include guards standard
// hh 971230 added RC_INVOKED wrapper
// hh 980113 Updated friend syntax of global methods and moved out of template definition.
// hh 981129 Rewrote
