1.1 --- a/epoc32/include/stdapis/stlport/stl/_set.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_set.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,481 @@
1.4 -_set.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_SET_H
1.35 +#define _STLP_INTERNAL_SET_H
1.36 +
1.37 +#ifndef _STLP_INTERNAL_TREE_H
1.38 +#include <stl/_tree.h>
1.39 +#endif
1.40 +
1.41 +#define set __WORKAROUND_RENAME(set)
1.42 +#define multiset __WORKAROUND_RENAME(multiset)
1.43 +
1.44 +_STLP_BEGIN_NAMESPACE
1.45 +
1.46 +template <class _Key, __DFL_TMPL_PARAM(_Compare,less<_Key>),
1.47 + _STLP_DEFAULT_ALLOCATOR_SELECT(_Key) >
1.48 +class set
1.49 +{
1.50 +public:
1.51 +// typedefs:
1.52 + typedef _Key key_type;
1.53 + typedef _Key value_type;
1.54 + typedef _Compare key_compare;
1.55 + typedef _Compare value_compare;
1.56 +private:
1.57 + typedef _Rb_tree<key_type, value_type,
1.58 + _Identity<value_type>, key_compare, _Alloc> _Rep_type;
1.59 +public:
1.60 + typedef typename _Rep_type::pointer pointer;
1.61 + typedef typename _Rep_type::const_pointer const_pointer;
1.62 + typedef typename _Rep_type::reference reference;
1.63 + typedef typename _Rep_type::const_reference const_reference;
1.64 + typedef typename _Rep_type::const_iterator const_iterator;
1.65 + typedef const_iterator iterator;
1.66 + typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
1.67 + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
1.68 + typedef typename _Rep_type::size_type size_type;
1.69 + typedef typename _Rep_type::difference_type difference_type;
1.70 + typedef typename _Rep_type::allocator_type allocator_type;
1.71 + typedef set<_Key,_Compare,_Alloc> _Self;
1.72 +
1.73 +private:
1.74 + _Rep_type _M_t; // red-black tree representing set
1.75 +public:
1.76 +
1.77 + // allocation/deallocation
1.78 +
1.79 + set() : _M_t(_Compare(), allocator_type()) {
1.80 + _STLP_POP_IF_CHECK
1.81 + }
1.82 +
1.83 +# ifdef _STLP_USE_TRAP_LEAVE
1.84 + set(const set<_Key,_Compare,_Alloc>& __x)
1.85 + {
1.86 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.87 + _M_t =__x._M_t;
1.88 + _STLP_POP_CLEANUP_ITEM
1.89 + }
1.90 +# else
1.91 + set(const set<_Key,_Compare,_Alloc>& __o)
1.92 + : _M_t(__o._M_t) {
1.93 + }
1.94 +# endif
1.95 +
1.96 + explicit set(const _Compare& __comp,
1.97 + const allocator_type& __a = allocator_type())
1.98 + : _M_t(__comp, __a) {
1.99 + _STLP_POP_IF_CHECK
1.100 + }
1.101 +
1.102 +#ifdef _STLP_MEMBER_TEMPLATES
1.103 + template <class _InputIterator>
1.104 + set(_InputIterator __first, _InputIterator __last)
1.105 + : _M_t(_Compare(), allocator_type())
1.106 + {
1.107 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.108 + _M_t.insert_unique(__first, __last);
1.109 + _STLP_POP_CLEANUP_ITEM
1.110 +}
1.111 +
1.112 +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
1.113 + template <class _InputIterator>
1.114 + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp)
1.115 + : _M_t(__comp, allocator_type()) {
1.116 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.117 + _M_t.insert_unique(__first, __last);
1.118 + _STLP_POP_CLEANUP_ITEM
1.119 + }
1.120 +# endif
1.121 + template <class _InputIterator>
1.122 + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
1.123 + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
1.124 + : _M_t(__comp, __a) {
1.125 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.126 + _M_t.insert_unique(__first, __last);
1.127 + _STLP_POP_CLEANUP_ITEM
1.128 + }
1.129 +#else
1.130 + set(const value_type* __first, const value_type* __last)
1.131 + : _M_t(_Compare(), allocator_type())
1.132 + {
1.133 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.134 + _M_t.insert_unique(__first, __last);
1.135 + _STLP_POP_CLEANUP_ITEM
1.136 + }
1.137 +
1.138 + set(const value_type* __first,
1.139 + const value_type* __last, const _Compare& __comp,
1.140 + const allocator_type& __a = allocator_type())
1.141 + : _M_t(__comp, __a) {
1.142 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.143 + _M_t.insert_unique(__first, __last);
1.144 + _STLP_POP_CLEANUP_ITEM
1.145 + }
1.146 +
1.147 + set(const_iterator __first, const_iterator __last)
1.148 + : _M_t(_Compare(), allocator_type())
1.149 + {
1.150 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.151 + _M_t.insert_unique(__first, __last);
1.152 + _STLP_POP_CLEANUP_ITEM
1.153 + }
1.154 +
1.155 + set(const_iterator __first, const_iterator __last, const _Compare& __comp,
1.156 + const allocator_type& __a = allocator_type())
1.157 + : _M_t(__comp, __a) {
1.158 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.159 + _M_t.insert_unique(__first, __last);
1.160 + _STLP_POP_CLEANUP_ITEM
1.161 + }
1.162 +#endif /* _STLP_MEMBER_TEMPLATES */
1.163 +
1.164 +
1.165 + set<_Key,_Compare,_Alloc>& operator=(const set<_Key, _Compare, _Alloc>& __x)
1.166 + {
1.167 + _M_t = __x._M_t;
1.168 + return *this;
1.169 + }
1.170 +
1.171 +#ifdef _STLP_USE_TRAP_LEAVE
1.172 +public:
1.173 + static void* operator new (size_t __n, TLeave) { return _STLP_StackHelper<bool>::_NewLC(__n); }
1.174 + static void* operator new (size_t __n) { return _STLP_StackHelper<bool>::_NewLC(__n); }
1.175 +#endif
1.176 +
1.177 +
1.178 + // accessors:
1.179 +
1.180 + key_compare key_comp() const { return _M_t.key_comp(); }
1.181 + value_compare value_comp() const { return _M_t.key_comp(); }
1.182 + allocator_type get_allocator() const { return _M_t.get_allocator(); }
1.183 +
1.184 + iterator begin() const { return _M_t.begin(); }
1.185 + iterator end() const { return _M_t.end(); }
1.186 + reverse_iterator rbegin() const { return _M_t.rbegin(); }
1.187 + reverse_iterator rend() const { return _M_t.rend(); }
1.188 + bool empty() const { return _M_t.empty(); }
1.189 + size_type size() const { return _M_t.size(); }
1.190 + size_type max_size() const { return _M_t.max_size(); }
1.191 + void swap(set<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
1.192 +
1.193 + // insert/erase
1.194 + pair<iterator,bool> insert(const value_type& __x) {
1.195 + typedef typename _Rep_type::iterator _Rep_iterator;
1.196 + pair<_Rep_iterator, bool> __p = _M_t.insert_unique(__x);
1.197 + return pair<iterator, bool>(__REINTERPRET_CAST(const iterator&,__p.first), __p.second);
1.198 + }
1.199 + iterator insert(iterator __position, const value_type& __x) {
1.200 + typedef typename _Rep_type::iterator _Rep_iterator;
1.201 + return _M_t.insert_unique((_Rep_iterator&)__position, __x);
1.202 + }
1.203 +#ifdef _STLP_MEMBER_TEMPLATES
1.204 + template <class _InputIterator>
1.205 + void insert(_InputIterator __first, _InputIterator __last) {
1.206 + _M_t.insert_unique(__first, __last);
1.207 + }
1.208 +#else
1.209 + void insert(const_iterator __first, const_iterator __last) {
1.210 + _M_t.insert_unique(__first, __last);
1.211 + }
1.212 + void insert(const value_type* __first, const value_type* __last) {
1.213 + _M_t.insert_unique(__first, __last);
1.214 + }
1.215 +#endif /* _STLP_MEMBER_TEMPLATES */
1.216 + void erase(iterator __position) {
1.217 + typedef typename _Rep_type::iterator _Rep_iterator;
1.218 + _M_t.erase((_Rep_iterator&)__position);
1.219 + }
1.220 + size_type erase(const key_type& __x) {
1.221 + return _M_t.erase(__x);
1.222 + }
1.223 + void erase(iterator __first, iterator __last) {
1.224 + typedef typename _Rep_type::iterator _Rep_iterator;
1.225 + _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
1.226 + }
1.227 + void clear() { _M_t.clear(); }
1.228 +
1.229 + // set operations:
1.230 +# if defined(_STLP_MEMBER_TEMPLATES) && ! defined ( _STLP_NO_EXTENSIONS )
1.231 + template <class _KT>
1.232 + iterator find(const _KT& __x) const { return _M_t.find(__x); }
1.233 +# else
1.234 + iterator find(const key_type& __x) const { return _M_t.find(__x); }
1.235 +# endif
1.236 + size_type count(const key_type& __x) const {
1.237 + return _M_t.find(__x) == _M_t.end() ? 0 : 1 ;
1.238 + }
1.239 + iterator lower_bound(const key_type& __x) const {
1.240 + return _M_t.lower_bound(__x);
1.241 + }
1.242 + iterator upper_bound(const key_type& __x) const {
1.243 + return _M_t.upper_bound(__x);
1.244 + }
1.245 + pair<iterator,iterator> equal_range(const key_type& __x) const {
1.246 + return _M_t.equal_range(__x);
1.247 + }
1.248 +};
1.249 +
1.250 +template <class _Key, __DFL_TMPL_PARAM(_Compare,less<_Key>),
1.251 + _STLP_DEFAULT_ALLOCATOR_SELECT(_Key) >
1.252 +class multiset
1.253 +{
1.254 +public:
1.255 + // typedefs:
1.256 +
1.257 + typedef _Key key_type;
1.258 + typedef _Key value_type;
1.259 + typedef _Compare key_compare;
1.260 + typedef _Compare value_compare;
1.261 +private:
1.262 + typedef _Rb_tree<key_type, value_type,
1.263 + _Identity<value_type>, key_compare, _Alloc> _Rep_type;
1.264 +public:
1.265 + typedef typename _Rep_type::pointer pointer;
1.266 + typedef typename _Rep_type::const_pointer const_pointer;
1.267 + typedef typename _Rep_type::reference reference;
1.268 + typedef typename _Rep_type::const_reference const_reference;
1.269 + typedef typename _Rep_type::const_iterator const_iterator;
1.270 + typedef const_iterator iterator;
1.271 + typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
1.272 + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
1.273 + typedef typename _Rep_type::size_type size_type;
1.274 + typedef typename _Rep_type::difference_type difference_type;
1.275 + typedef typename _Rep_type::allocator_type allocator_type;
1.276 +
1.277 + typedef multiset<_Key,_Compare,_Alloc> _Self;
1.278 +
1.279 +private:
1.280 + _Rep_type _M_t; // red-black tree representing multiset
1.281 +public:
1.282 + // allocation/deallocation
1.283 +
1.284 + multiset() : _M_t(_Compare(), allocator_type()) {
1.285 + _STLP_POP_IF_CHECK
1.286 + }
1.287 +
1.288 +# ifdef _STLP_USE_TRAP_LEAVE
1.289 + multiset(const multiset<_Key,_Compare,_Alloc>& __x)
1.290 + {
1.291 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.292 + _M_t =__x._M_t;
1.293 + _STLP_POP_CLEANUP_ITEM
1.294 + }
1.295 +# else
1.296 + multiset(const multiset<_Key,_Compare,_Alloc>& __o)
1.297 + : _M_t(__o._M_t) {
1.298 + }
1.299 +# endif
1.300 +
1.301 + explicit multiset(const _Compare& __comp,
1.302 + const allocator_type& __a = allocator_type())
1.303 + : _M_t(__comp, __a) {
1.304 + _STLP_POP_IF_CHECK
1.305 + }
1.306 +
1.307 +#ifdef _STLP_MEMBER_TEMPLATES
1.308 +
1.309 + template <class _InputIterator>
1.310 + multiset(_InputIterator __first, _InputIterator __last)
1.311 + : _M_t(_Compare(), allocator_type())
1.312 + {
1.313 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.314 + _M_t.insert_equal(__first, __last);
1.315 + _STLP_POP_CLEANUP_ITEM
1.316 + }
1.317 +
1.318 +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
1.319 + template <class _InputIterator>
1.320 + multiset(_InputIterator __first, _InputIterator __last,
1.321 + const _Compare& __comp)
1.322 + : _M_t(__comp, allocator_type()) {
1.323 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.324 + _M_t.insert_equal(__first, __last);
1.325 + _STLP_POP_CLEANUP_ITEM
1.326 + }
1.327 +# endif
1.328 + template <class _InputIterator>
1.329 + multiset(_InputIterator __first, _InputIterator __last,
1.330 + const _Compare& __comp,
1.331 + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
1.332 + : _M_t(__comp, __a) {
1.333 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.334 + _M_t.insert_equal(__first, __last);
1.335 + _STLP_POP_CLEANUP_ITEM
1.336 + }
1.337 +
1.338 +#else
1.339 +
1.340 + multiset(const value_type* __first, const value_type* __last)
1.341 + : _M_t(_Compare(), allocator_type())
1.342 + {
1.343 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.344 + _M_t.insert_equal(__first, __last);
1.345 + _STLP_POP_CLEANUP_ITEM
1.346 + }
1.347 +
1.348 + multiset(const value_type* __first, const value_type* __last,
1.349 + const _Compare& __comp,
1.350 + const allocator_type& __a = allocator_type())
1.351 + : _M_t(__comp, __a) {
1.352 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.353 + _M_t.insert_equal(__first, __last);
1.354 + _STLP_POP_CLEANUP_ITEM
1.355 + }
1.356 +
1.357 + multiset(const_iterator __first, const_iterator __last)
1.358 + : _M_t(_Compare(), allocator_type())
1.359 + {
1.360 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.361 + _M_t.insert_equal(__first, __last);
1.362 + _STLP_POP_CLEANUP_ITEM
1.363 + }
1.364 +
1.365 + multiset(const_iterator __first, const_iterator __last,
1.366 + const _Compare& __comp,
1.367 + const allocator_type& __a = allocator_type())
1.368 + : _M_t(__comp, __a) {
1.369 + _STLP_PUSH_CLEANUP_ITEM(_Self, this)
1.370 + _M_t.insert_equal(__first, __last);
1.371 + _STLP_POP_CLEANUP_ITEM
1.372 + }
1.373 +
1.374 +#endif /* _STLP_MEMBER_TEMPLATES */
1.375 +
1.376 + multiset<_Key,_Compare,_Alloc>&
1.377 + operator=(const multiset<_Key,_Compare,_Alloc>& __x) {
1.378 + _M_t = __x._M_t;
1.379 + return *this;
1.380 + }
1.381 +
1.382 +#ifdef _STLP_USE_TRAP_LEAVE
1.383 +public:
1.384 + static void* operator new (size_t __n, TLeave) { return _STLP_StackHelper<bool>::_NewLC(__n); }
1.385 + static void* operator new (size_t __n) { return _STLP_StackHelper<bool>::_NewLC(__n); }
1.386 +#endif
1.387 +
1.388 + // accessors:
1.389 +
1.390 + key_compare key_comp() const { return _M_t.key_comp(); }
1.391 + value_compare value_comp() const { return _M_t.key_comp(); }
1.392 + allocator_type get_allocator() const { return _M_t.get_allocator(); }
1.393 +
1.394 + iterator begin() const { return _M_t.begin(); }
1.395 + iterator end() const { return _M_t.end(); }
1.396 + reverse_iterator rbegin() const { return _M_t.rbegin(); }
1.397 + reverse_iterator rend() const { return _M_t.rend(); }
1.398 + bool empty() const { return _M_t.empty(); }
1.399 + size_type size() const { return _M_t.size(); }
1.400 + size_type max_size() const { return _M_t.max_size(); }
1.401 + void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
1.402 +
1.403 + // insert/erase
1.404 + iterator insert(const value_type& __x) {
1.405 + return _M_t.insert_equal(__x);
1.406 + }
1.407 + iterator insert(iterator __position, const value_type& __x) {
1.408 + typedef typename _Rep_type::iterator _Rep_iterator;
1.409 + return _M_t.insert_equal((_Rep_iterator&)__position, __x);
1.410 + }
1.411 +
1.412 +#ifdef _STLP_MEMBER_TEMPLATES
1.413 + template <class _InputIterator>
1.414 + void insert(_InputIterator __first, _InputIterator __last) {
1.415 + _M_t.insert_equal(__first, __last);
1.416 + }
1.417 +#else
1.418 + void insert(const value_type* __first, const value_type* __last) {
1.419 + _M_t.insert_equal(__first, __last);
1.420 + }
1.421 + void insert(const_iterator __first, const_iterator __last) {
1.422 + _M_t.insert_equal(__first, __last);
1.423 + }
1.424 +#endif /* _STLP_MEMBER_TEMPLATES */
1.425 + void erase(iterator __position) {
1.426 + typedef typename _Rep_type::iterator _Rep_iterator;
1.427 + _M_t.erase((_Rep_iterator&)__position);
1.428 + }
1.429 + size_type erase(const key_type& __x) {
1.430 + return _M_t.erase(__x);
1.431 + }
1.432 + void erase(iterator __first, iterator __last) {
1.433 + typedef typename _Rep_type::iterator _Rep_iterator;
1.434 + _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
1.435 + }
1.436 + void clear() { _M_t.clear(); }
1.437 +
1.438 + // multiset operations:
1.439 +
1.440 +# if defined(_STLP_MEMBER_TEMPLATES) && ! defined ( _STLP_NO_EXTENSIONS )
1.441 + template <class _KT>
1.442 + iterator find(const _KT& __x) const { return _M_t.find(__x); }
1.443 +# else
1.444 + iterator find(const key_type& __x) const { return _M_t.find(__x); }
1.445 +# endif
1.446 + size_type count(const key_type& __x) const { return _M_t.count(__x); }
1.447 + iterator lower_bound(const key_type& __x) const {
1.448 + return _M_t.lower_bound(__x);
1.449 + }
1.450 + iterator upper_bound(const key_type& __x) const {
1.451 + return _M_t.upper_bound(__x);
1.452 + }
1.453 + pair<iterator,iterator> equal_range(const key_type& __x) const {
1.454 + return _M_t.equal_range(__x);
1.455 + }
1.456 +};
1.457 +
1.458 +# define _STLP_TEMPLATE_HEADER template <class _Key, class _Compare, class _Alloc>
1.459 +# define _STLP_TEMPLATE_CONTAINER set<_Key,_Compare,_Alloc>
1.460 +# include <stl/_relops_cont.h>
1.461 +# undef _STLP_TEMPLATE_CONTAINER
1.462 +# define _STLP_TEMPLATE_CONTAINER multiset<_Key,_Compare,_Alloc>
1.463 +# include <stl/_relops_cont.h>
1.464 +# undef _STLP_TEMPLATE_CONTAINER
1.465 +# undef _STLP_TEMPLATE_HEADER
1.466 +
1.467 +_STLP_END_NAMESPACE
1.468 +
1.469 +// do a cleanup
1.470 +# undef set
1.471 +# undef multiset
1.472 +// provide a way to access full funclionality
1.473 +# define __set__ __FULL_NAME(set)
1.474 +# define __multiset__ __FULL_NAME(multiset)
1.475 +
1.476 +# ifdef _STLP_USE_WRAPPER_FOR_ALLOC_PARAM
1.477 +# include <stl/wrappers/_set.h>
1.478 +# endif
1.479 +
1.480 +#endif /* _STLP_INTERNAL_SET_H */
1.481 +
1.482 +// Local Variables:
1.483 +// mode:C++
1.484 +// End:
1.485 +