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