epoc32/include/tools/stlport/stl/_queue.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_queue.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,253 @@
     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_BASE_H
    1.49 +#  include <stl/_function_base.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 +class queue
    1.67 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
    1.68 +#  if defined (_STLP_QUEUE_ARGS)
    1.69 +            : public __stlport_class<queue<_Tp> >
    1.70 +#  else
    1.71 +            : public __stlport_class<queue<_Tp, _Sequence> >
    1.72 +#  endif
    1.73 +#endif
    1.74 +{
    1.75 +# if defined ( _STLP_QUEUE_ARGS )
    1.76 +  typedef deque<_Tp> _Sequence;
    1.77 +  typedef queue<_Tp> _Self;
    1.78 +# else
    1.79 +  typedef queue<_Tp, _Sequence> _Self;
    1.80 +# endif
    1.81 +public:
    1.82 +  typedef typename _Sequence::value_type      value_type;
    1.83 +  typedef typename _Sequence::size_type       size_type;
    1.84 +  typedef          _Sequence                  container_type;
    1.85 +
    1.86 +  typedef typename _Sequence::reference       reference;
    1.87 +  typedef typename _Sequence::const_reference const_reference;
    1.88 +
    1.89 +protected:
    1.90 +  //c is a Standard name (23.2.3.1), do no make it STLport naming convention compliant.
    1.91 +  _Sequence c;
    1.92 +public:
    1.93 +  queue() : c() {}
    1.94 +  explicit queue(const _Sequence& __c) : c(__c) {}
    1.95 +
    1.96 +  queue(__move_source<_Self> src)
    1.97 +    : c(_STLP_PRIV _AsMoveSource(src.get().c)) {}
    1.98 +
    1.99 +  bool empty() const { return c.empty(); }
   1.100 +  size_type size() const { return c.size(); }
   1.101 +  reference front() { return c.front(); }
   1.102 +  const_reference front() const { return c.front(); }
   1.103 +  reference back() { return c.back(); }
   1.104 +  const_reference back() const { return c.back(); }
   1.105 +  void push(const value_type& __x) { c.push_back(__x); }
   1.106 +  void pop() { c.pop_front(); }
   1.107 +  const _Sequence& _Get_s() const { return c; }
   1.108 +};
   1.109 +
   1.110 +#ifndef _STLP_QUEUE_ARGS
   1.111 +#  define _STLP_QUEUE_ARGS _Tp, _Sequence
   1.112 +#  define _STLP_QUEUE_HEADER_ARGS class _Tp, class _Sequence
   1.113 +#else
   1.114 +#  define _STLP_QUEUE_HEADER_ARGS class _Tp
   1.115 +#endif
   1.116 +
   1.117 +template < _STLP_QUEUE_HEADER_ARGS >
   1.118 +inline bool _STLP_CALL
   1.119 +operator==(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) {
   1.120 +  return __x._Get_s() == __y._Get_s();
   1.121 +}
   1.122 +
   1.123 +template < _STLP_QUEUE_HEADER_ARGS >
   1.124 +inline bool _STLP_CALL
   1.125 +operator<(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) {
   1.126 +  return __x._Get_s() < __y._Get_s();
   1.127 +}
   1.128 +
   1.129 +_STLP_RELOPS_OPERATORS( template < _STLP_QUEUE_HEADER_ARGS >, queue<_STLP_QUEUE_ARGS > )
   1.130 +
   1.131 +# if !(defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) || defined ( _STLP_TEMPLATE_PARAM_SUBTYPE_BUG ))
   1.132 +template <class _Tp, class _Sequence = vector<_Tp>,
   1.133 +          class _Compare = less<_STLP_HEADER_TYPENAME _Sequence::value_type> >
   1.134 +# elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
   1.135 +template <class _Tp>
   1.136 +# else
   1.137 +template <class _Tp, class _Sequence, class _Compare>
   1.138 +# endif
   1.139 +class priority_queue
   1.140 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
   1.141 +#  if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS)
   1.142 +            : public __stlport_class<priority_queue<_Tp> >
   1.143 +#  else
   1.144 +            : public __stlport_class<priority_queue<_Tp, _Sequence> >
   1.145 +#  endif
   1.146 +#endif
   1.147 +{
   1.148 +# ifdef _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS
   1.149 +  typedef vector<_Tp> _Sequence;
   1.150 +  typedef less< typename vector<_Tp>::value_type> _Compare;
   1.151 +  typedef priority_queue<_Tp> _Self;
   1.152 +# else
   1.153 +  typedef priority_queue<_Tp, _Sequence, _Compare> _Self;
   1.154 +# endif
   1.155 +public:
   1.156 +  typedef typename _Sequence::value_type      value_type;
   1.157 +  typedef typename _Sequence::size_type       size_type;
   1.158 +  typedef          _Sequence                  container_type;
   1.159 +
   1.160 +  typedef typename _Sequence::reference       reference;
   1.161 +  typedef typename _Sequence::const_reference const_reference;
   1.162 +protected:
   1.163 +  //c is a Standard name (23.2.3.2), do no make it STLport naming convention compliant.
   1.164 +  _Sequence c;
   1.165 +  _Compare comp;
   1.166 +public:
   1.167 +  priority_queue() : c() {}
   1.168 +  explicit priority_queue(const _Compare& __x) :  c(), comp(__x) {}
   1.169 +  priority_queue(const _Compare& __x, const _Sequence& __s)
   1.170 +    : c(__s), comp(__x)
   1.171 +    { make_heap(c.begin(), c.end(), comp); }
   1.172 +
   1.173 +  priority_queue(__move_source<_Self> src)
   1.174 +    : c(_STLP_PRIV _AsMoveSource(src.get().c)),
   1.175 +      comp(_STLP_PRIV _AsMoveSource(src.get().comp)) {}
   1.176 +
   1.177 +#ifdef _STLP_MEMBER_TEMPLATES
   1.178 +  template <class _InputIterator>
   1.179 +  priority_queue(_InputIterator __first, _InputIterator __last)
   1.180 +    : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
   1.181 +
   1.182 +  template <class _InputIterator>
   1.183 +  priority_queue(_InputIterator __first,
   1.184 +                 _InputIterator __last, const _Compare& __x)
   1.185 +    : c(__first, __last), comp(__x)
   1.186 +    { make_heap(c.begin(), c.end(), comp); }
   1.187 +
   1.188 +  template <class _InputIterator>
   1.189 +  priority_queue(_InputIterator __first, _InputIterator __last,
   1.190 +                 const _Compare& __x, const _Sequence& __s)
   1.191 +  : c(__s), comp(__x)
   1.192 +  {
   1.193 +    c.insert(c.end(), __first, __last);
   1.194 +    make_heap(c.begin(), c.end(), comp);
   1.195 +  }
   1.196 +
   1.197 +#else /* _STLP_MEMBER_TEMPLATES */
   1.198 +  priority_queue(const value_type* __first, const value_type* __last)
   1.199 +    : c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
   1.200 +
   1.201 +  priority_queue(const value_type* __first, const value_type* __last,
   1.202 +                 const _Compare& __x)
   1.203 +    : c(__first, __last), comp(__x)
   1.204 +    { make_heap(c.begin(), c.end(), comp); }
   1.205 +
   1.206 +  priority_queue(const value_type* __first, const value_type* __last,
   1.207 +                 const _Compare& __x, const _Sequence& __c)
   1.208 +    : c(__c), comp(__x)
   1.209 +  {
   1.210 +    c.insert(c.end(), __first, __last);
   1.211 +    make_heap(c.begin(), c.end(), comp);
   1.212 +  }
   1.213 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.214 +
   1.215 +  bool empty() const { return c.empty(); }
   1.216 +  size_type size() const { return c.size(); }
   1.217 +  const_reference top() const { return c.front(); }
   1.218 +  void push(const value_type& __x) {
   1.219 +    _STLP_TRY {
   1.220 +      c.push_back(__x);
   1.221 +      push_heap(c.begin(), c.end(), comp);
   1.222 +    }
   1.223 +    _STLP_UNWIND(c.clear())
   1.224 +  }
   1.225 +  void pop() {
   1.226 +    _STLP_TRY {
   1.227 +      pop_heap(c.begin(), c.end(), comp);
   1.228 +      c.pop_back();
   1.229 +    }
   1.230 +    _STLP_UNWIND(c.clear())
   1.231 +  }
   1.232 +};
   1.233 +
   1.234 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
   1.235 +template <class _Tp, class _Sequence>
   1.236 +struct __move_traits<queue<_Tp, _Sequence> > :
   1.237 +  _STLP_PRIV __move_traits_aux<_Sequence>
   1.238 +{};
   1.239 +
   1.240 +template <class _Tp, class _Sequence, class _Compare>
   1.241 +struct __move_traits<priority_queue<_Tp, _Sequence, _Compare> > :
   1.242 +  _STLP_PRIV __move_traits_aux2<_Sequence, _Compare>
   1.243 +{};
   1.244 +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
   1.245 +
   1.246 +_STLP_END_NAMESPACE
   1.247 +
   1.248 +#undef _STLP_QUEUE_ARGS
   1.249 +#undef _STLP_QUEUE_HEADER_ARGS
   1.250 +#undef comp
   1.251 +
   1.252 +#endif /* _STLP_INTERNAL_QUEUE_H */
   1.253 +
   1.254 +// Local Variables:
   1.255 +// mode:C++
   1.256 +// End: