// queue standard header
#ifndef _QUEUE_
#define _QUEUE_

#pragma info(none)
#ifndef __CHKHDR__
#  pragma report(level, E)
#endif
#pragma info(restore)

#if __IBMCPP__ < 400
#error This file to be used only with IBM VisualAge C++ v4 and later compilers.
#endif /* __IBMCPP__ */

#pragma namemangling(ansi)

   /********************************************************************/
   /*  <queue> header file                                             */
   /*                                                                  */
   /*  VisualAge C++, Version 4.0                                      */
   /*    Licensed Material - Property of IBM                           */
   /*                                                                  */
   /*  5801-AAR and Other Materials                                    */
   /*                                                                  */
   /*  (c) Copyright IBM Corp 1991, 1998. All rights reserved.         */
   /*                                                                  */
   /*                                                                  */
   /*  Licensed Materials.                                             */
   /*                                                                  */
   /*  Dinkum C++ Library                                              */
   /*  Copyright (c) 1998.  Licensed to IBM Corp. and its suppliers.   */
   /*                                                                  */
   /********************************************************************/

#include <algorithm>
#include <deque>
#include <functional>
#include <vector>
_STD_BEGIN
		// TEMPLATE CLASS queue
template<class _Ty, class _C _TDEF(deque<_Ty>) >
	class queue {
public:
	typedef _C container_type;
	typedef typename _C::value_type value_type;
	typedef typename _C::size_type size_type;
	queue()
		: c() {}
	explicit queue(const _C& _Cont)
		: c(_Cont) {}
	bool empty() const
		{return (c.empty()); }
	size_type size() const
		{return (c.size()); }
	value_type& front()
		{return (c.front()); }
	const value_type& front() const
		{return (c.front()); }
	value_type& back()
		{return (c.back()); }
	const value_type& back() const
		{return (c.back()); }
	void push(const value_type& _X)
		{c.push_back(_X); }
	void pop()
		{c.pop_front(); }
	bool _Eq(const queue<_Ty, _C>& _X) const
		{return (c == _X.c); }
	bool _Lt(const queue<_Ty, _C>& _X) const
		{return (c < _X.c); }
protected:
	_C c;
	};
		// queue TEMPLATE FUNCTIONS
template<class _Ty, class _C> inline
	bool operator==(const queue<_Ty, _C>& _X,
		const queue<_Ty, _C>& _Y)
	{return (_X._Eq(_Y)); }
template<class _Ty, class _C> inline
	bool operator!=(const queue<_Ty, _C>& _X,
		const queue<_Ty, _C>& _Y)
	{return (!(_X == _Y)); }
template<class _Ty, class _C> inline
	bool operator<(const queue<_Ty, _C>& _X,
		const queue<_Ty, _C>& _Y)
	{return (_X._Lt(_Y)); }
template<class _Ty, class _C> inline
	bool operator>(const queue<_Ty, _C>& _X,
		const queue<_Ty, _C>& _Y)
	{return (_Y < _X); }
template<class _Ty, class _C> inline
	bool operator<=(const queue<_Ty, _C>& _X,
		const queue<_Ty, _C>& _Y)
	{return (!(_Y < _X)); }
template<class _Ty, class _C> inline
	bool operator>=(const queue<_Ty, _C>& _X,
		const queue<_Ty, _C>& _Y)
	{return (!(_X < _Y)); }
		// TEMPLATE CLASS priority_queue
template<class _Ty, class _C _TDEF(vector<_Ty>),
	class _Pr _TDEF(less<typename _C::value_type>) >
	class priority_queue {
public:
	typedef _C container_type;
	typedef typename _C::value_type value_type;
	typedef typename _C::size_type size_type;
	priority_queue()
		: c(), comp() {}
	explicit priority_queue(const _Pr& _X)
		: c(), comp(_X) {}
	priority_queue(const _Pr& _X, const _C& _Cont)
		: c(_Cont), comp(_X)
		{make_heap(c.begin(), c.end(), comp); }
	template<class _It>
		priority_queue(_It _F, _It _L)
		: c(_F, _L), comp()
		{make_heap(c.begin(), c.end(), comp); }
	template<class _It>
		priority_queue(_It _F, _It _L, const _Pr& _X)
		: c(_F, _L), comp(_X)
		{make_heap(c.begin(), c.end(), comp); }
	template<class _It>
		priority_queue(_It _F, _It _L, const _Pr& _X,
			const _C& _Cont)
		: c(_Cont), comp(_X)
		{c.insert(c.end(), _F, _L);
		make_heap(c.begin(), c.end(), comp); }
	bool empty() const
		{return (c.empty()); }
	size_type size() const
		{return (c.size()); }
	const value_type& top() const
		{return (c.front()); }
	void push(const value_type& _X)
		{c.push_back(_X);
		push_heap(c.begin(), c.end(), comp); }
	void pop()
		{pop_heap(c.begin(), c.end(), comp);
		c.pop_back(); }
protected:
	_C c;
	_Pr comp;
	};
_STD_END

#pragma namemangling()

#pragma info(none)
#ifndef __CHKHDR__
#  pragma report(pop)
#endif
#pragma info(restore)

#endif /* _QUEUE_ */

/*
 * Copyright (c) 1995 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.
V2.2:0081 */
