epoc32/include/stdapis/stlport/stl/debug/_deque.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 0 061f57f2323e
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  *
     3  * Copyright (c) 1994
     4  * Hewlett-Packard Company
     5  *
     6  * Copyright (c) 1996,1997
     7  * Silicon Graphics Computer Systems, Inc.
     8  *
     9  * Copyright (c) 1997
    10  * Moscow Center for SPARC Technology
    11  *
    12  * Copyright (c) 1999 
    13  * Boris Fomitchev
    14  *
    15  * This material is provided "as is", with absolutely no warranty expressed
    16  * or implied. Any use is at your own risk.
    17  *
    18  * Permission to use or copy this software for any purpose is hereby granted 
    19  * without fee, provided the above notices are retained on all copies.
    20  * Permission to modify the code and to distribute modified code is granted,
    21  * provided the above notices are retained, and a notice that the code was
    22  * modified is included with the above copyright notice.
    23  *
    24  */
    25 
    26 /* NOTE: This is an internal header file, included by other STL headers.
    27  *   You should not attempt to use it directly.
    28  */
    29 
    30 #ifndef _STLP_INTERNAL_DBG_DEQUE_H
    31 #define _STLP_INTERNAL_DBG_DEQUE_H
    32 
    33 #include <stl/debug/_iterator.h>
    34 
    35 # if !defined (_STLP_USE_WRAPPER_FOR_ALLOC_PARAM) && !defined (_STLP_NO_DEFAULT_NON_TYPE_PARAM)
    36 #  undef  _DBG_deque
    37 #  define _DBG_deque deque
    38 # endif
    39 
    40 # define _DEQUE_WRAPPER _DBG_deque<_Tp,_Alloc>
    41 
    42 # define _STLP_DEQUE_SUPER   __WORKAROUND_DBG_RENAME(deque) <_Tp,_Alloc>
    43 
    44 _STLP_BEGIN_NAMESPACE
    45 
    46 # ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
    47 template <class _Tp, class _Alloc>
    48 inline _Tp* value_type(const  _DBG_iter_base< _STLP_DEQUE_SUPER >&) {
    49   return (_Tp*)0;
    50 }
    51 template <class _Tp, class _Alloc>
    52 inline random_access_iterator_tag iterator_category(const  _DBG_iter_base< _STLP_DEQUE_SUPER >&) {
    53   return random_access_iterator_tag();
    54 }
    55 # endif
    56 
    57 template <class _Tp, _STLP_DBG_ALLOCATOR_SELECT(_Tp) >
    58 class _DBG_deque : public _STLP_DEQUE_SUPER {
    59 
    60   typedef _DBG_deque<_Tp,_Alloc> _Self;
    61   typedef _STLP_DEQUE_SUPER _Base;
    62 
    63 public:                         // Basic types
    64 
    65   __IMPORT_CONTAINER_TYPEDEFS(_Base)
    66 
    67 public:                         // Iterators
    68   typedef _DBG_iter< _STLP_DEQUE_SUPER, _Nonconst_traits<value_type> >    iterator;
    69   typedef _DBG_iter< _STLP_DEQUE_SUPER, _Const_traits<value_type> >   const_iterator;
    70 
    71   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
    72 
    73 protected:
    74   __owned_list _M_iter_list;
    75   void _Invalidate_iterator(const iterator& __it) { 
    76     __invalidate_iterator(&_M_iter_list,__it);
    77   }
    78   void _Invalidate_all() {
    79       _M_iter_list._Invalidate_all();
    80   }
    81 
    82 public:                         // Basic accessors
    83   iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
    84   iterator end() { return iterator(&_M_iter_list, this->_M_finish); }
    85   const_iterator begin() const { 
    86     return const_iterator(&_M_iter_list, this->_M_start); 
    87   }
    88   const_iterator end() const { 
    89     return const_iterator(&_M_iter_list,  this->_M_finish); 
    90   }
    91 
    92   reverse_iterator rbegin() { return reverse_iterator(end()); }
    93   reverse_iterator rend() { return reverse_iterator(begin()); }
    94   const_reverse_iterator rbegin() const 
    95     { return const_reverse_iterator(end()); }
    96   const_reverse_iterator rend() const 
    97     { return const_reverse_iterator(begin()); }
    98 
    99   reference operator[](size_type __n)
   100     { return begin()[difference_type(__n)]; }
   101   const_reference operator[](size_type __n) const 
   102     { return begin()[difference_type(__n)]; }
   103 
   104   reference front() { return *begin(); }
   105   reference back() {
   106     iterator __tmp = end();
   107     --__tmp;
   108     return *__tmp;
   109   }
   110   const_reference front() const { return *begin(); }
   111   const_reference back() const {
   112     const_iterator __tmp = end();
   113     --__tmp;
   114     return *__tmp;
   115   }
   116 
   117 public:                         // Constructor, destructor.
   118 
   119   const _Base* _Get_base() const { return (const _Base*)this; }
   120 
   121   explicit _DBG_deque(const allocator_type& __a = allocator_type()) :
   122     _STLP_DEQUE_SUPER(__a), _M_iter_list(_Get_base()) {}
   123   _DBG_deque(const _Self& __x) : _STLP_DEQUE_SUPER(__x), _M_iter_list(_Get_base()) {}
   124   _DBG_deque(size_type __n, const value_type& __value,
   125         const allocator_type& __a = allocator_type()) : 
   126     _STLP_DEQUE_SUPER(__n, __value, __a), _M_iter_list(_Get_base()) {}
   127   explicit _DBG_deque(size_type __n) : _STLP_DEQUE_SUPER(__n), _M_iter_list(_Get_base()) {}
   128 
   129 #ifdef _STLP_MEMBER_TEMPLATES
   130   template <class _InputIterator>
   131   _DBG_deque(_InputIterator __first, _InputIterator __last,
   132         const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) : 
   133     _STLP_DEQUE_SUPER(__first, __last, __a) , _M_iter_list(_Get_base()) {}
   134 # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
   135   template <class _InputIterator>
   136   _DBG_deque(_InputIterator __first, _InputIterator __last):
   137     _STLP_DEQUE_SUPER(__first, __last, allocator_type()) , _M_iter_list(_Get_base()) {}
   138 # endif
   139 #else /* _STLP_MEMBER_TEMPLATES */
   140   _DBG_deque(const value_type* __first, const value_type* __last,
   141         const allocator_type& __a = allocator_type()) 
   142     : _STLP_DEQUE_SUPER(__first, __last, __a), _M_iter_list(_Get_base()) {}
   143 
   144   _DBG_deque(const_iterator __first, const_iterator __last,
   145         const allocator_type& __a = allocator_type()) 
   146     : _STLP_DEQUE_SUPER(__first._M_iterator, __last._M_iterator, __a), 
   147       _M_iter_list(_Get_base()) {}
   148 #endif /* _STLP_MEMBER_TEMPLATES */
   149 
   150   _Self& operator= (const _Self& __x) {
   151     _Invalidate_all();
   152     (_Base&)*this = (const _Base&)__x; 
   153     return *this;
   154   }
   155 
   156   void swap(_Self& __x) {
   157     _M_iter_list._Swap_owners(__x._M_iter_list);
   158     _Base::swap(__x);
   159   }
   160 
   161 public: 
   162   void assign(size_type __n, const _Tp& __val) {
   163     _Base::assign(__n, __val);
   164   }
   165 
   166 #ifdef _STLP_MEMBER_TEMPLATES
   167 
   168   template <class _InputIterator>
   169   void assign(_InputIterator __first, _InputIterator __last) {
   170     _Base::assign(__first, __last);
   171   }
   172 #endif /* _STLP_MEMBER_TEMPLATES */
   173 
   174 public:                         // push_* and pop_*
   175   
   176   void push_back(const value_type& __t) {
   177     _Invalidate_all();
   178     _Base::push_back(__t);
   179   }
   180 
   181   void push_back() {
   182     _Invalidate_all();
   183     _Base::push_back();
   184   }
   185 
   186   void push_front(const value_type& __t) {
   187     _Invalidate_all();
   188     _Base::push_front(__t);
   189   }
   190 
   191   void push_front() {
   192     _Base::push_front();
   193     _Invalidate_all();
   194   }
   195 
   196 
   197   void pop_back() {
   198     _Invalidate_iterator(end());
   199     _Base::pop_back();
   200   }
   201 
   202   void pop_front() {
   203     _Invalidate_iterator(begin());        
   204     _Base::pop_front();
   205   }
   206 
   207 public:                         // Insert
   208 
   209   iterator insert(iterator __position, const value_type& __x) {
   210     _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
   211     // fbp : invalidation !
   212     return iterator(&_M_iter_list, _Base::insert(__position._M_iterator, __x));
   213   }
   214 
   215   iterator insert(iterator __position) { 
   216     _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
   217     // fbp : invalidation !
   218     return iterator(&_M_iter_list, _Base::insert(__position._M_iterator));
   219   }
   220 
   221   void insert(iterator __position, size_type __n, const value_type& __x) {
   222     _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
   223     // fbp : invalidation !
   224     _Base::insert(__position._M_iterator, __n, __x);
   225   }
   226 
   227 #ifdef _STLP_MEMBER_TEMPLATES  
   228   template <class _InputIterator>
   229   void insert(iterator __position, _InputIterator __first, _InputIterator __last) {
   230     _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
   231     // fbp : invalidation !
   232     _Base::insert(__position._M_iterator, __first, __last);
   233   }
   234 #else /* _STLP_MEMBER_TEMPLATES */
   235   void insert(iterator __position,
   236               const value_type* __first, const value_type* __last) {
   237     _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
   238     _Base::insert(__position._M_iterator, __first, __last);
   239   }
   240   void insert(iterator __position,
   241               const_iterator __first, const_iterator __last) {
   242     _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
   243     _Base::insert(__position._M_iterator, __first._M_iterator, __last._M_iterator);
   244   }
   245 #endif /* _STLP_MEMBER_TEMPLATES */
   246 
   247 public:                         // Erase
   248   iterator erase(iterator __pos) {
   249     _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos) && (__pos != end()))
   250     return iterator (&_M_iter_list, _Base::erase(__pos._M_iterator));
   251   }
   252 
   253   iterator erase(iterator __first, iterator __last) {
   254     _STLP_DEBUG_CHECK(__first >= begin() && __last <= end())
   255     return iterator (&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));
   256   }
   257   
   258   void clear() {
   259     _Invalidate_all();
   260     _Base::clear();
   261   }
   262 };
   263 
   264 #define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
   265 #define _STLP_TEMPLATE_CONTAINER _DBG_deque<_Tp, _Alloc>
   266 #define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DEQUE_SUPER
   267 #include <stl/debug/_relops_cont.h>
   268 #undef _STLP_TEMPLATE_CONTAINER_BASE
   269 #undef _STLP_TEMPLATE_CONTAINER
   270 #undef _STLP_TEMPLATE_HEADER
   271 
   272 _STLP_END_NAMESPACE 
   273 
   274 # undef _DBG_deque
   275 # undef _STLP_DEQUE_SUPER
   276   
   277 #endif /* _STLP_INTERNAL_DEQUE_H */
   278 
   279 // Local Variables:
   280 // mode:C++
   281 // End: