1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_queue.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,212 @@
1.4 +/*
1.5 + *
1.6 + * Copyright (c) 1994
1.7 + * Hewlett-Packard Company
1.8 + *
1.9 + * Copyright (c) 1996,1997
1.10 + * Silicon Graphics Computer Systems, Inc.
1.11 + *
1.12 + * Copyright (c) 1997
1.13 + * Moscow Center for SPARC Technology
1.14 + *
1.15 + * Copyright (c) 1999
1.16 + * Boris Fomitchev
1.17 + *
1.18 + * This material is provided "as is", with absolutely no warranty expressed
1.19 + * or implied. Any use is at your own risk.
1.20 + *
1.21 + * Permission to use or copy this software for any purpose is hereby granted
1.22 + * without fee, provided the above notices are retained on all copies.
1.23 + * Permission to modify the code and to distribute modified code is granted,
1.24 + * provided the above notices are retained, and a notice that the code was
1.25 + * modified is included with the above copyright notice.
1.26 + *
1.27 + */
1.28 +
1.29 +/* NOTE: This is an internal header file, included by other STL headers.
1.30 + * You should not attempt to use it directly.
1.31 + */
1.32 +
1.33 +#ifndef _STLP_INTERNAL_QUEUE_H
1.34 +#define _STLP_INTERNAL_QUEUE_H
1.35 +
1.36 +#ifndef _STLP_INTERNAL_DEQUE_H
1.37 +# include <stl/_deque.h>
1.38 +#endif
1.39 +
1.40 +#ifndef _STLP_INTERNAL_VECTOR_H
1.41 +# include <stl/_vector.h>
1.42 +#endif
1.43 +
1.44 +#ifndef _STLP_INTERNAL_HEAP_H
1.45 +# include <stl/_heap.h>
1.46 +#endif
1.47 +
1.48 +#ifndef _STLP_INTERNAL_FUNCTION_H
1.49 +# include <stl/_function.h>
1.50 +#endif
1.51 +
1.52 +#if defined(__SC__) && !defined(__DMC__) //*ty 12/07/2001 - since "comp" is a built-in type and reserved under SCpp
1.53 +#define comp _Comp
1.54 +#endif
1.55 +
1.56 +_STLP_BEGIN_NAMESPACE
1.57 +
1.58 +# if ! defined ( _STLP_LIMITED_DEFAULT_TEMPLATES )
1.59 +template <class _Tp, class _Sequence = deque<_Tp> >
1.60 +# elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
1.61 +# define _STLP_QUEUE_ARGS _Tp
1.62 +template <class _Tp>
1.63 +# else
1.64 +template <class _Tp, class _Sequence>
1.65 +# endif
1.66 +
1.67 +class queue {
1.68 +# if defined ( _STLP_QUEUE_ARGS )
1.69 + typedef deque<_Tp> _Sequence;
1.70 +# endif
1.71 +public:
1.72 + typedef typename _Sequence::value_type value_type;
1.73 + typedef typename _Sequence::size_type size_type;
1.74 + typedef _Sequence container_type;
1.75 +
1.76 + typedef typename _Sequence::reference reference;
1.77 + typedef typename _Sequence::const_reference const_reference;
1.78 +
1.79 +protected:
1.80 + _Sequence c;
1.81 +public:
1.82 + queue() : c() {}
1.83 + explicit queue(const _Sequence& __c) : c(__c) {}
1.84 +
1.85 + bool empty() const { return c.empty(); }
1.86 + size_type size() const { return c.size(); }
1.87 + reference front() { return c.front(); }
1.88 + const_reference front() const { return c.front(); }
1.89 + reference back() { return c.back(); }
1.90 + const_reference back() const { return c.back(); }
1.91 + void push(const value_type& __x) { c.push_back(__x); }
1.92 + void pop() { c.pop_front(); }
1.93 + const _Sequence& _Get_c() const { return c; }
1.94 +};
1.95 +
1.96 +# ifndef _STLP_QUEUE_ARGS
1.97 +# define _STLP_QUEUE_ARGS _Tp, _Sequence
1.98 +# define _STLP_QUEUE_HEADER_ARGS class _Tp, class _Sequence
1.99 +# else
1.100 +# define _STLP_QUEUE_HEADER_ARGS class _Tp
1.101 +# endif
1.102 +
1.103 +template < _STLP_QUEUE_HEADER_ARGS >
1.104 +inline bool _STLP_CALL
1.105 +operator==(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y)
1.106 +{
1.107 + return __x._Get_c() == __y._Get_c();
1.108 +}
1.109 +
1.110 +template < _STLP_QUEUE_HEADER_ARGS >
1.111 +inline bool _STLP_CALL
1.112 +operator<(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y)
1.113 +{
1.114 + return __x._Get_c() < __y._Get_c();
1.115 +}
1.116 +
1.117 +_STLP_RELOPS_OPERATORS( template < _STLP_QUEUE_HEADER_ARGS >, queue<_STLP_QUEUE_ARGS > )
1.118 +
1.119 +# if !(defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) || defined ( _STLP_TEMPLATE_PARAM_SUBTYPE_BUG ))
1.120 +template <class _Tp, class _Sequence = vector<_Tp>,
1.121 + class _Compare = less<_STLP_HEADER_TYPENAME _Sequence::value_type> >
1.122 +# elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
1.123 +template <class _Tp>
1.124 +# else
1.125 +template <class _Tp, class _Sequence, class _Compare>
1.126 +# endif
1.127 +class priority_queue {
1.128 +# ifdef _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS
1.129 + typedef vector<_Tp> _Sequence;
1.130 + typedef less< typename vector<_Tp>::value_type> _Compare;
1.131 +# endif
1.132 +public:
1.133 + typedef typename _Sequence::value_type value_type;
1.134 + typedef typename _Sequence::size_type size_type;
1.135 + typedef _Sequence container_type;
1.136 +
1.137 + typedef typename _Sequence::reference reference;
1.138 + typedef typename _Sequence::const_reference const_reference;
1.139 +protected:
1.140 + _Sequence c;
1.141 + _Compare comp;
1.142 +public:
1.143 + priority_queue() : c() {}
1.144 + explicit priority_queue(const _Compare& __x) : c(), comp(__x) {}
1.145 + explicit priority_queue(const _Compare& __x, const _Sequence& __s)
1.146 + : c(__s), comp(__x)
1.147 + { make_heap(c.begin(), c.end(), comp); }
1.148 +
1.149 +#ifdef _STLP_MEMBER_TEMPLATES
1.150 + template <class _InputIterator>
1.151 + priority_queue(_InputIterator __first, _InputIterator __last)
1.152 + : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
1.153 +
1.154 + template <class _InputIterator>
1.155 + priority_queue(_InputIterator __first,
1.156 + _InputIterator __last, const _Compare& __x)
1.157 + : c(__first, __last), comp(__x)
1.158 + { make_heap(c.begin(), c.end(), comp); }
1.159 +
1.160 + template <class _InputIterator>
1.161 + priority_queue(_InputIterator __first, _InputIterator __last,
1.162 + const _Compare& __x, const _Sequence& __s)
1.163 + : c(__s), comp(__x)
1.164 + {
1.165 + c.insert(c.end(), __first, __last);
1.166 + make_heap(c.begin(), c.end(), comp);
1.167 + }
1.168 +
1.169 +#else /* _STLP_MEMBER_TEMPLATES */
1.170 + priority_queue(const value_type* __first, const value_type* __last)
1.171 + : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
1.172 +
1.173 + priority_queue(const value_type* __first, const value_type* __last,
1.174 + const _Compare& __x)
1.175 + : c(__first, __last), comp(__x)
1.176 + { make_heap(c.begin(), c.end(), comp); }
1.177 +
1.178 + priority_queue(const value_type* __first, const value_type* __last,
1.179 + const _Compare& __x, const _Sequence& __c)
1.180 + : c(__c), comp(__x)
1.181 + {
1.182 + c.insert(c.end(), __first, __last);
1.183 + make_heap(c.begin(), c.end(), comp);
1.184 + }
1.185 +#endif /* _STLP_MEMBER_TEMPLATES */
1.186 +
1.187 + bool empty() const { return c.empty(); }
1.188 + size_type size() const { return c.size(); }
1.189 + const_reference top() const { return c.front(); }
1.190 + void push(const value_type& __x) {
1.191 + _STLP_TRY {
1.192 + c.push_back(__x);
1.193 + push_heap(c.begin(), c.end(), comp);
1.194 + }
1.195 + _STLP_UNWIND(c.clear());
1.196 + }
1.197 + void pop() {
1.198 + _STLP_TRY {
1.199 + pop_heap(c.begin(), c.end(), comp);
1.200 + c.pop_back();
1.201 + }
1.202 + _STLP_UNWIND(c.clear());
1.203 + }
1.204 +};
1.205 +
1.206 +_STLP_END_NAMESPACE
1.207 +
1.208 +# undef _STLP_QUEUE_ARGS
1.209 +# undef _STLP_QUEUE_HEADER_ARGS
1.210 +
1.211 +#endif /* _STLP_INTERNAL_QUEUE_H */
1.212 +
1.213 +// Local Variables:
1.214 +// mode:C++
1.215 +// End: