epoc32/include/tools/stlport/stl/_set.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/_set.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,402 @@
     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_SET_H
    1.34 +#define _STLP_INTERNAL_SET_H
    1.35 +
    1.36 +#ifndef _STLP_INTERNAL_TREE_H
    1.37 +#  include <stl/_tree.h>
    1.38 +#endif
    1.39 +
    1.40 +#if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
    1.41 +
    1.42 +_STLP_BEGIN_NAMESPACE
    1.43 +
    1.44 +//Specific iterator traits creation
    1.45 +_STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits)
    1.46 +
    1.47 +template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>),
    1.48 +                     _STLP_DEFAULT_ALLOCATOR_SELECT(_Key) >
    1.49 +class set
    1.50 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
    1.51 +          : public __stlport_class<set<_Key, _Compare, _Alloc> >
    1.52 +#endif
    1.53 +{
    1.54 +  typedef set<_Key, _Compare, _Alloc> _Self;
    1.55 +public:
    1.56 +// typedefs:
    1.57 +  typedef _Key     key_type;
    1.58 +  typedef _Key     value_type;
    1.59 +  typedef _Compare key_compare;
    1.60 +  typedef _Compare value_compare;
    1.61 +
    1.62 +private:
    1.63 +  //Specific iterator traits creation
    1.64 +  typedef _STLP_PRIV _SetTraitsT<value_type> _SetTraits;
    1.65 +
    1.66 +public:
    1.67 +  //Following typedef have to be public for __move_traits specialization.
    1.68 +  typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
    1.69 +                              value_type, _STLP_PRIV _Identity<value_type>,
    1.70 +                              _SetTraits, _Alloc> _Rep_type;
    1.71 +
    1.72 +  typedef typename _Rep_type::pointer pointer;
    1.73 +  typedef typename _Rep_type::const_pointer const_pointer;
    1.74 +  typedef typename _Rep_type::reference reference;
    1.75 +  typedef typename _Rep_type::const_reference const_reference;
    1.76 +  typedef typename _Rep_type::iterator iterator;
    1.77 +  typedef typename _Rep_type::const_iterator const_iterator;
    1.78 +  typedef typename _Rep_type::reverse_iterator reverse_iterator;
    1.79 +  typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
    1.80 +  typedef typename _Rep_type::size_type size_type;
    1.81 +  typedef typename _Rep_type::difference_type difference_type;
    1.82 +  typedef typename _Rep_type::allocator_type allocator_type;
    1.83 +
    1.84 +private:
    1.85 +  _Rep_type _M_t;  // red-black tree representing set
    1.86 +  _STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
    1.87 +
    1.88 +public:
    1.89 +
    1.90 +  // allocation/deallocation
    1.91 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
    1.92 +  explicit set(const _Compare& __comp = _Compare(),
    1.93 +               const allocator_type& __a = allocator_type())
    1.94 +#else
    1.95 +  set()
    1.96 +    : _M_t(_Compare(), allocator_type()) {}
    1.97 +  explicit set(const _Compare& __comp)
    1.98 +    : _M_t(__comp, allocator_type()) {}
    1.99 +  set(const _Compare& __comp, const allocator_type& __a)
   1.100 +#endif
   1.101 +    : _M_t(__comp, __a) {}
   1.102 +
   1.103 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.104 +  template <class _InputIterator>
   1.105 +  set(_InputIterator __first, _InputIterator __last)
   1.106 +    : _M_t(_Compare(), allocator_type())
   1.107 +    { _M_t.insert_unique(__first, __last); }
   1.108 +
   1.109 +#  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   1.110 +  template <class _InputIterator>
   1.111 +  set(_InputIterator __first, _InputIterator __last, const _Compare& __comp)
   1.112 +    : _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); }
   1.113 +#  endif
   1.114 +  template <class _InputIterator>
   1.115 +  set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
   1.116 +      const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
   1.117 +    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
   1.118 +#else
   1.119 +  set(const value_type* __first, const value_type* __last)
   1.120 +    : _M_t(_Compare(), allocator_type())
   1.121 +    { _M_t.insert_unique(__first, __last); }
   1.122 +
   1.123 +  set(const value_type* __first,
   1.124 +      const value_type* __last, const _Compare& __comp,
   1.125 +      const allocator_type& __a = allocator_type())
   1.126 +    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
   1.127 +
   1.128 +  set(const_iterator __first, const_iterator __last)
   1.129 +    : _M_t(_Compare(), allocator_type())
   1.130 +    { _M_t.insert_unique(__first, __last); }
   1.131 +
   1.132 +  set(const_iterator __first, const_iterator __last, const _Compare& __comp,
   1.133 +      const allocator_type& __a = allocator_type())
   1.134 +    : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
   1.135 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.136 +
   1.137 +  set(const _Self& __x) : _M_t(__x._M_t) {}
   1.138 +
   1.139 +  set(__move_source<_Self> src)
   1.140 +    : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
   1.141 +
   1.142 +  _Self& operator=(const _Self& __x) {
   1.143 +    _M_t = __x._M_t;
   1.144 +    return *this;
   1.145 +  }
   1.146 +
   1.147 +  // accessors:
   1.148 +  key_compare key_comp() const { return _M_t.key_comp(); }
   1.149 +  value_compare value_comp() const { return _M_t.key_comp(); }
   1.150 +  allocator_type get_allocator() const { return _M_t.get_allocator(); }
   1.151 +
   1.152 +  iterator begin() { return _M_t.begin(); }
   1.153 +  iterator end() { return _M_t.end(); }
   1.154 +  const_iterator begin() const { return _M_t.begin(); }
   1.155 +  const_iterator end() const { return _M_t.end(); }
   1.156 +  reverse_iterator rbegin() { return _M_t.rbegin(); }
   1.157 +  reverse_iterator rend() { return _M_t.rend(); }
   1.158 +  const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
   1.159 +  const_reverse_iterator rend() const { return _M_t.rend(); }
   1.160 +  bool empty() const { return _M_t.empty(); }
   1.161 +  size_type size() const { return _M_t.size(); }
   1.162 +  size_type max_size() const { return _M_t.max_size(); }
   1.163 +  void swap(_Self& __x) { _M_t.swap(__x._M_t); }
   1.164 +
   1.165 +  // insert/erase
   1.166 +  pair<iterator,bool> insert(const value_type& __x)
   1.167 +  { return _M_t.insert_unique(__x); }
   1.168 +  iterator insert(iterator __pos, const value_type& __x)
   1.169 +  { return _M_t.insert_unique( __pos , __x); }
   1.170 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.171 +  template <class _InputIterator>
   1.172 +  void insert(_InputIterator __first, _InputIterator __last)
   1.173 +  { _M_t.insert_unique(__first, __last); }
   1.174 +#else
   1.175 +  void insert(const_iterator __first, const_iterator __last)
   1.176 +  { _M_t.insert_unique(__first, __last); }
   1.177 +  void insert(const value_type* __first, const value_type* __last)
   1.178 +  { _M_t.insert_unique(__first, __last); }
   1.179 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.180 +  void erase(iterator __pos) { _M_t.erase( __pos ); }
   1.181 +  size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); }
   1.182 +  void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last ); }
   1.183 +  void clear() { _M_t.clear(); }
   1.184 +
   1.185 +  // set operations:
   1.186 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.187 +  const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
   1.188 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.189 +  iterator find(const _KT& __x) { return _M_t.find(__x); }
   1.190 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.191 +  size_type count(const _KT& __x) const
   1.192 +  { return _M_t.find(__x) == _M_t.end() ? 0 : 1 ; }
   1.193 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.194 +  iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
   1.195 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.196 +  const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
   1.197 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.198 +  iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
   1.199 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.200 +  const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
   1.201 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.202 +  pair<iterator, iterator> equal_range(const _KT& __x)
   1.203 +  { return _M_t.equal_range_unique(__x); }
   1.204 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.205 +  pair<const_iterator, const_iterator> equal_range(const _KT& __x) const
   1.206 +  { return _M_t.equal_range_unique(__x); }
   1.207 +};
   1.208 +
   1.209 +//Specific iterator traits creation
   1.210 +_STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits)
   1.211 +
   1.212 +template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>),
   1.213 +          _STLP_DEFAULT_ALLOCATOR_SELECT(_Key) >
   1.214 +class multiset
   1.215 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
   1.216 +               : public __stlport_class<multiset<_Key, _Compare, _Alloc> >
   1.217 +#endif
   1.218 +{
   1.219 +  typedef multiset<_Key, _Compare, _Alloc> _Self;
   1.220 +public:
   1.221 +  // typedefs:
   1.222 +
   1.223 +  typedef _Key     key_type;
   1.224 +  typedef _Key     value_type;
   1.225 +  typedef _Compare key_compare;
   1.226 +  typedef _Compare value_compare;
   1.227 +
   1.228 +private:
   1.229 +  //Specific iterator traits creation
   1.230 +  typedef _STLP_PRIV _MultisetTraitsT<value_type> _MultisetTraits;
   1.231 +
   1.232 +public:
   1.233 +  //Following typedef have to be public for __move_traits specialization.
   1.234 +  typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
   1.235 +                              value_type, _STLP_PRIV _Identity<value_type>,
   1.236 +                              _MultisetTraits, _Alloc> _Rep_type;
   1.237 +
   1.238 +  typedef typename _Rep_type::pointer pointer;
   1.239 +  typedef typename _Rep_type::const_pointer const_pointer;
   1.240 +  typedef typename _Rep_type::reference reference;
   1.241 +  typedef typename _Rep_type::const_reference const_reference;
   1.242 +  typedef typename _Rep_type::iterator iterator;
   1.243 +  typedef typename _Rep_type::const_iterator const_iterator;
   1.244 +  typedef typename _Rep_type::reverse_iterator reverse_iterator;
   1.245 +  typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
   1.246 +  typedef typename _Rep_type::size_type size_type;
   1.247 +  typedef typename _Rep_type::difference_type difference_type;
   1.248 +  typedef typename _Rep_type::allocator_type allocator_type;
   1.249 +
   1.250 +private:
   1.251 +  _Rep_type _M_t;  // red-black tree representing multiset
   1.252 +  _STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
   1.253 +
   1.254 +public:
   1.255 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.256 +  explicit multiset(const _Compare& __comp = _Compare(),
   1.257 +                    const allocator_type& __a = allocator_type())
   1.258 +#else
   1.259 +  multiset()
   1.260 +    : _M_t(_Compare(), allocator_type()) {}
   1.261 +  explicit multiset(const _Compare& __comp)
   1.262 +    : _M_t(__comp, allocator_type()) {}
   1.263 +  multiset(const _Compare& __comp, const allocator_type& __a)
   1.264 +#endif
   1.265 +    : _M_t(__comp, __a) {}
   1.266 +
   1.267 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.268 +  template <class _InputIterator>
   1.269 +  multiset(_InputIterator __first, _InputIterator __last)
   1.270 +    : _M_t(_Compare(), allocator_type())
   1.271 +    { _M_t.insert_equal(__first, __last); }
   1.272 +
   1.273 +  template <class _InputIterator>
   1.274 +  multiset(_InputIterator __first, _InputIterator __last,
   1.275 +           const _Compare& __comp,
   1.276 +           const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
   1.277 +    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
   1.278 +#  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   1.279 +  template <class _InputIterator>
   1.280 +  multiset(_InputIterator __first, _InputIterator __last,
   1.281 +           const _Compare& __comp)
   1.282 +    : _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); }
   1.283 +#  endif
   1.284 +#else
   1.285 +  multiset(const value_type* __first, const value_type* __last)
   1.286 +    : _M_t(_Compare(), allocator_type())
   1.287 +    { _M_t.insert_equal(__first, __last); }
   1.288 +
   1.289 +  multiset(const value_type* __first, const value_type* __last,
   1.290 +           const _Compare& __comp,
   1.291 +           const allocator_type& __a = allocator_type())
   1.292 +    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
   1.293 +
   1.294 +  multiset(const_iterator __first, const_iterator __last)
   1.295 +    : _M_t(_Compare(), allocator_type())
   1.296 +    { _M_t.insert_equal(__first, __last); }
   1.297 +
   1.298 +  multiset(const_iterator __first, const_iterator __last,
   1.299 +           const _Compare& __comp,
   1.300 +           const allocator_type& __a = allocator_type())
   1.301 +    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
   1.302 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.303 +
   1.304 +  multiset(const _Self& __x) : _M_t(__x._M_t) {}
   1.305 +  _Self& operator=(const _Self& __x) {
   1.306 +    _M_t = __x._M_t;
   1.307 +    return *this;
   1.308 +  }
   1.309 +
   1.310 +  multiset(__move_source<_Self> src)
   1.311 +    : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
   1.312 +
   1.313 +  // accessors:
   1.314 +  key_compare key_comp() const { return _M_t.key_comp(); }
   1.315 +  value_compare value_comp() const { return _M_t.key_comp(); }
   1.316 +  allocator_type get_allocator() const { return _M_t.get_allocator(); }
   1.317 +
   1.318 +  iterator begin() { return _M_t.begin(); }
   1.319 +  iterator end() { return _M_t.end(); }
   1.320 +  const_iterator begin() const { return _M_t.begin(); }
   1.321 +  const_iterator end() const { return _M_t.end(); }
   1.322 +  reverse_iterator rbegin() { return _M_t.rbegin(); }
   1.323 +  reverse_iterator rend() { return _M_t.rend(); }
   1.324 +  const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
   1.325 +  const_reverse_iterator rend() const { return _M_t.rend(); }
   1.326 +  bool empty() const { return _M_t.empty(); }
   1.327 +  size_type size() const { return _M_t.size(); }
   1.328 +  size_type max_size() const { return _M_t.max_size(); }
   1.329 +  void swap(_Self& __x) { _M_t.swap(__x._M_t); }
   1.330 +
   1.331 +  // insert/erase
   1.332 +  iterator insert(const value_type& __x)
   1.333 +  { return _M_t.insert_equal(__x); }
   1.334 +  iterator insert(iterator __pos, const value_type& __x)
   1.335 +  { return _M_t.insert_equal(__pos, __x); }
   1.336 +
   1.337 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.338 +  template <class _InputIterator>
   1.339 +  void insert(_InputIterator __first, _InputIterator __last)
   1.340 +  { _M_t.insert_equal(__first, __last); }
   1.341 +#else
   1.342 +  void insert(const value_type* __first, const value_type* __last)
   1.343 +  { _M_t.insert_equal(__first, __last); }
   1.344 +  void insert(const_iterator __first, const_iterator __last)
   1.345 +  { _M_t.insert_equal(__first, __last); }
   1.346 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.347 +  void erase(iterator __pos) { _M_t.erase( __pos ); }
   1.348 +  size_type erase(const key_type& __x) { return _M_t.erase(__x); }
   1.349 +  void erase(iterator __first, iterator __last) { _M_t.erase( __first, __last ); }
   1.350 +  void clear() { _M_t.clear(); }
   1.351 +
   1.352 +  // multiset operations:
   1.353 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.354 +  iterator find(const _KT& __x) { return _M_t.find(__x); }
   1.355 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.356 +  const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
   1.357 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.358 +  size_type count(const _KT& __x) const { return _M_t.count(__x); }
   1.359 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.360 +  iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
   1.361 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.362 +  const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
   1.363 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.364 +  iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
   1.365 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.366 +  const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
   1.367 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.368 +  pair<iterator, iterator> equal_range(const _KT& __x) { return _M_t.equal_range(__x); }
   1.369 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.370 +  pair<const_iterator, const_iterator> equal_range(const _KT& __x) const { return _M_t.equal_range(__x); }
   1.371 +};
   1.372 +
   1.373 +#else
   1.374 +#  include <stl/pointers/_set.h>
   1.375 +_STLP_BEGIN_NAMESPACE
   1.376 +#endif /* _STLP_USE_PTR_SPECIALIZATIONS */
   1.377 +
   1.378 +#define _STLP_TEMPLATE_HEADER template <class _Key, class _Compare, class _Alloc>
   1.379 +#define _STLP_TEMPLATE_CONTAINER set<_Key,_Compare,_Alloc>
   1.380 +#include <stl/_relops_cont.h>
   1.381 +#undef  _STLP_TEMPLATE_CONTAINER
   1.382 +#define _STLP_TEMPLATE_CONTAINER multiset<_Key,_Compare,_Alloc>
   1.383 +#include <stl/_relops_cont.h>
   1.384 +#undef  _STLP_TEMPLATE_CONTAINER
   1.385 +#undef  _STLP_TEMPLATE_HEADER
   1.386 +
   1.387 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
   1.388 +template <class _Key, class _Compare, class _Alloc>
   1.389 +struct __move_traits<set<_Key,_Compare,_Alloc> > :
   1.390 +  _STLP_PRIV __move_traits_aux<typename set<_Key,_Compare,_Alloc>::_Rep_type>
   1.391 +{};
   1.392 +
   1.393 +template <class _Key, class _Compare, class _Alloc>
   1.394 +struct __move_traits<multiset<_Key,_Compare,_Alloc> > :
   1.395 +  _STLP_PRIV __move_traits_aux<typename multiset<_Key,_Compare,_Alloc>::_Rep_type>
   1.396 +{};
   1.397 +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
   1.398 +
   1.399 +_STLP_END_NAMESPACE
   1.400 +
   1.401 +#endif /* _STLP_INTERNAL_SET_H */
   1.402 +
   1.403 +// Local Variables:
   1.404 +// mode:C++
   1.405 +// End: