Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

149 lines
3.6 KiB

// stack standard header
#pragma once
#ifndef _STACK_
#define _STACK_
#include <deque>
#pragma pack(push,8)
#pragma warning(push,3)
_STD_BEGIN
// TEMPLATE CLASS stack
template<class _Ty,
class _Container = deque<_Ty> >
class stack
{ // LIFO queue implemented with a container
public:
typedef _Container container_type;
typedef typename _Container::value_type value_type;
typedef typename _Container::size_type size_type;
stack()
: c()
{ // construct with empty container
}
explicit stack(const _Container& _Cont)
: c(_Cont)
{ // construct by copying specified container
}
bool empty() const
{ // test if stack is empty
return (c.empty());
}
size_type size() const
{ // test length of stack
return (c.size());
}
value_type& top()
{ // return last element of mutable stack
return (c.back());
}
const value_type& top() const
{ // return last element of nonmutable stack
return (c.back());
}
void push(const value_type& _Val)
{ // insert element at end
c.push_back(_Val);
}
void pop()
{ // erase last element
c.pop_back();
}
bool _Eq(const stack<_Ty, _Container>& _Right) const
{ // test for stack equality
return (c == _Right.c);
}
bool _Lt(const stack<_Ty, _Container>& _Right) const
{ // test if this < _Right for stacks
return (c < _Right.c);
}
protected:
_Container c; // the underlying container
};
// stack TEMPLATE FUNCTIONS
template<class _Ty,
class _Container> inline
bool operator==(const stack<_Ty, _Container>& _Left,
const stack<_Ty, _Container>& _Right)
{ // test for stack equality
return (_Left._Eq(_Right));
}
template<class _Ty,
class _Container> inline
bool operator!=(const stack<_Ty, _Container>& _Left,
const stack<_Ty, _Container>& _Right)
{ // test for stack inequality
return (!(_Left == _Right));
}
template<class _Ty,
class _Container> inline
bool operator<(const stack<_Ty, _Container>& _Left,
const stack<_Ty, _Container>& _Right)
{ // test if _Left < _Right for stacks
return (_Left._Lt(_Right));
}
template<class _Ty,
class _Container> inline
bool operator>(const stack<_Ty, _Container>& _Left,
const stack<_Ty, _Container>& _Right)
{ // test if _Left > _Right for stacks
return (_Right < _Left);
}
template<class _Ty,
class _Container> inline
bool operator<=(const stack<_Ty, _Container>& _Left,
const stack<_Ty, _Container>& _Right)
{ // test if _Left <= _Right for stacks
return (!(_Right < _Left));
}
template<class _Ty,
class _Container> inline
bool operator>=(const stack<_Ty, _Container>& _Left,
const stack<_Ty, _Container>& _Right)
{ // test if _Left >= _Right for stacks
return (!(_Left < _Right));
}
_STD_END
#pragma warning(pop)
#pragma pack(pop)
#endif /* _STACK_ */
/*
* Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
*/
/*
* This file is derived from software bearing the following
* restrictions:
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this
* software and its documentation for any purpose is hereby
* granted without fee, provided that the above copyright notice
* appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation.
* Hewlett-Packard Company makes no representations about the
* suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
V3.10:0009 */