Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_queue.h
Go to the documentation of this file.
00001 /* 00002 * 00003 * Copyright (c) 1994 00004 * Hewlett-Packard Company 00005 * 00006 * Copyright (c) 1996,1997 00007 * Silicon Graphics Computer Systems, Inc. 00008 * 00009 * Copyright (c) 1997 00010 * Moscow Center for SPARC Technology 00011 * 00012 * Copyright (c) 1999 00013 * Boris Fomitchev 00014 * 00015 * This material is provided "as is", with absolutely no warranty expressed 00016 * or implied. Any use is at your own risk. 00017 * 00018 * Permission to use or copy this software for any purpose is hereby granted 00019 * without fee, provided the above notices are retained on all copies. 00020 * Permission to modify the code and to distribute modified code is granted, 00021 * provided the above notices are retained, and a notice that the code was 00022 * modified is included with the above copyright notice. 00023 * 00024 */ 00025 00026 /* NOTE: This is an internal header file, included by other STL headers. 00027 * You should not attempt to use it directly. 00028 */ 00029 00030 #ifndef _STLP_INTERNAL_QUEUE_H 00031 #define _STLP_INTERNAL_QUEUE_H 00032 00033 #ifndef _STLP_INTERNAL_DEQUE_H 00034 # include <stl/_deque.h> 00035 #endif 00036 00037 #ifndef _STLP_INTERNAL_VECTOR_H 00038 # include <stl/_vector.h> 00039 #endif 00040 00041 #ifndef _STLP_INTERNAL_HEAP_H 00042 # include <stl/_heap.h> 00043 #endif 00044 00045 #ifndef _STLP_INTERNAL_FUNCTION_BASE_H 00046 # include <stl/_function_base.h> 00047 #endif 00048 00049 _STLP_BEGIN_NAMESPACE 00050 00051 # if ! defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) 00052 template <class _Tp, class _Sequence = deque<_Tp> > 00053 # elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS ) 00054 # define _STLP_QUEUE_ARGS _Tp 00055 template <class _Tp> 00056 # else 00057 template <class _Tp, class _Sequence> 00058 # endif 00059 class queue 00060 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00061 # if defined (_STLP_QUEUE_ARGS) 00062 : public __stlport_class<queue<_Tp> > 00063 # else 00064 : public __stlport_class<queue<_Tp, _Sequence> > 00065 # endif 00066 #endif 00067 { 00068 # if defined ( _STLP_QUEUE_ARGS ) 00069 typedef deque<_Tp> _Sequence; 00070 typedef queue<_Tp> _Self; 00071 # else 00072 typedef queue<_Tp, _Sequence> _Self; 00073 # endif 00074 public: 00075 typedef typename _Sequence::value_type value_type; 00076 typedef typename _Sequence::size_type size_type; 00077 typedef _Sequence container_type; 00078 00079 typedef typename _Sequence::reference reference; 00080 typedef typename _Sequence::const_reference const_reference; 00081 00082 protected: 00083 //c is a Standard name (23.2.3.1), do no make it STLport naming convention compliant. 00084 _Sequence c; 00085 public: 00086 queue() : c() {} 00087 explicit queue(const _Sequence& __c) : c(__c) {} 00088 00089 #if !defined (_STLP_NO_MOVE_SEMANTIC) 00090 queue(__move_source<_Self> src) 00091 : c(_STLP_PRIV _AsMoveSource(src.get().c)) {} 00092 #endif 00093 00094 bool empty() const { return c.empty(); } 00095 size_type size() const { return c.size(); } 00096 reference front() { return c.front(); } 00097 const_reference front() const { return c.front(); } 00098 reference back() { return c.back(); } 00099 const_reference back() const { return c.back(); } 00100 void push(const value_type& __x) { c.push_back(__x); } 00101 void pop() { c.pop_front(); } 00102 const _Sequence& _Get_s() const { return c; } 00103 00104 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 00105 void _M_swap_workaround(_Self& __x) { 00106 _Sequence __tmp = c; 00107 c = __x.c; 00108 __x.c = __tmp; 00109 } 00110 #endif 00111 }; 00112 00113 #ifndef _STLP_QUEUE_ARGS 00114 # define _STLP_QUEUE_ARGS _Tp, _Sequence 00115 # define _STLP_QUEUE_HEADER_ARGS class _Tp, class _Sequence 00116 #else 00117 # define _STLP_QUEUE_HEADER_ARGS class _Tp 00118 #endif 00119 00120 template < _STLP_QUEUE_HEADER_ARGS > 00121 inline bool _STLP_CALL 00122 operator==(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) { 00123 return __x._Get_s() == __y._Get_s(); 00124 } 00125 00126 template < _STLP_QUEUE_HEADER_ARGS > 00127 inline bool _STLP_CALL 00128 operator<(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) { 00129 return __x._Get_s() < __y._Get_s(); 00130 } 00131 00132 _STLP_RELOPS_OPERATORS( template < _STLP_QUEUE_HEADER_ARGS >, queue<_STLP_QUEUE_ARGS > ) 00133 00134 # if !(defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) || defined ( _STLP_TEMPLATE_PARAM_SUBTYPE_BUG )) 00135 template <class _Tp, class _Sequence = vector<_Tp>, 00136 class _Compare = less<_STLP_HEADER_TYPENAME _Sequence::value_type> > 00137 # elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS ) 00138 template <class _Tp> 00139 # else 00140 template <class _Tp, class _Sequence, class _Compare> 00141 # endif 00142 class priority_queue 00143 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00144 # if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) 00145 : public __stlport_class<priority_queue<_Tp> > 00146 # else 00147 : public __stlport_class<priority_queue<_Tp, _Sequence> > 00148 # endif 00149 #endif 00150 { 00151 # ifdef _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS 00152 typedef vector<_Tp> _Sequence; 00153 typedef less< typename vector<_Tp>::value_type> _Compare; 00154 typedef priority_queue<_Tp> _Self; 00155 # else 00156 typedef priority_queue<_Tp, _Sequence, _Compare> _Self; 00157 # endif 00158 public: 00159 typedef typename _Sequence::value_type value_type; 00160 typedef typename _Sequence::size_type size_type; 00161 typedef _Sequence container_type; 00162 00163 typedef typename _Sequence::reference reference; 00164 typedef typename _Sequence::const_reference const_reference; 00165 protected: 00166 //c is a Standard name (23.2.3.2), do no make it STLport naming convention compliant. 00167 _Sequence c; 00168 _Compare comp; 00169 public: 00170 priority_queue() : c() {} 00171 explicit priority_queue(const _Compare& __x) : c(), comp(__x) {} 00172 priority_queue(const _Compare& __x, const _Sequence& __s) 00173 : c(__s), comp(__x) 00174 { make_heap(c.begin(), c.end(), comp); } 00175 00176 #if !defined (_STLP_NO_MOVE_SEMANTIC) 00177 priority_queue(__move_source<_Self> src) 00178 : c(_STLP_PRIV _AsMoveSource(src.get().c)), 00179 comp(_STLP_PRIV _AsMoveSource(src.get().comp)) {} 00180 #endif 00181 00182 #ifdef _STLP_MEMBER_TEMPLATES 00183 template <class _InputIterator> 00184 priority_queue(_InputIterator __first, _InputIterator __last) 00185 : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } 00186 00187 template <class _InputIterator> 00188 priority_queue(_InputIterator __first, 00189 _InputIterator __last, const _Compare& __x) 00190 : c(__first, __last), comp(__x) 00191 { make_heap(c.begin(), c.end(), comp); } 00192 00193 template <class _InputIterator> 00194 priority_queue(_InputIterator __first, _InputIterator __last, 00195 const _Compare& __x, const _Sequence& __s) 00196 : c(__s), comp(__x) 00197 { 00198 c.insert(c.end(), __first, __last); 00199 make_heap(c.begin(), c.end(), comp); 00200 } 00201 00202 #else /* _STLP_MEMBER_TEMPLATES */ 00203 priority_queue(const value_type* __first, const value_type* __last) 00204 : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } 00205 00206 priority_queue(const value_type* __first, const value_type* __last, 00207 const _Compare& __x) 00208 : c(__first, __last), comp(__x) 00209 { make_heap(c.begin(), c.end(), comp); } 00210 00211 priority_queue(const value_type* __first, const value_type* __last, 00212 const _Compare& __x, const _Sequence& __c) 00213 : c(__c), comp(__x) 00214 { 00215 c.insert(c.end(), __first, __last); 00216 make_heap(c.begin(), c.end(), comp); 00217 } 00218 #endif /* _STLP_MEMBER_TEMPLATES */ 00219 00220 bool empty() const { return c.empty(); } 00221 size_type size() const { return c.size(); } 00222 const_reference top() const { return c.front(); } 00223 void push(const value_type& __x) { 00224 _STLP_TRY { 00225 c.push_back(__x); 00226 push_heap(c.begin(), c.end(), comp); 00227 } 00228 _STLP_UNWIND(c.clear()) 00229 } 00230 void pop() { 00231 _STLP_TRY { 00232 pop_heap(c.begin(), c.end(), comp); 00233 c.pop_back(); 00234 } 00235 _STLP_UNWIND(c.clear()) 00236 } 00237 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 00238 void _M_swap_workaround(_Self& __x) { 00239 _Sequence __tmp = c; 00240 c = __x.c; 00241 __x.c = __tmp; 00242 } 00243 #endif 00244 }; 00245 00246 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) 00247 template <class _Tp, class _Sequence> 00248 struct __move_traits<queue<_Tp, _Sequence> > : 00249 _STLP_PRIV __move_traits_aux<_Sequence> 00250 {}; 00251 00252 template <class _Tp, class _Sequence, class _Compare> 00253 struct __move_traits<priority_queue<_Tp, _Sequence, _Compare> > : 00254 _STLP_PRIV __move_traits_aux2<_Sequence, _Compare> 00255 {}; 00256 #endif 00257 00258 _STLP_END_NAMESPACE 00259 00260 #undef _STLP_QUEUE_ARGS 00261 #undef _STLP_QUEUE_HEADER_ARGS 00262 #undef comp 00263 00264 #endif /* _STLP_INTERNAL_QUEUE_H */ 00265 00266 // Local Variables: 00267 // mode:C++ 00268 // End: Generated on Sat May 26 2012 04:27:56 for ReactOS by
1.7.6.1
|