Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_vector.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 2003 00003 * Francois Dumont 00004 * 00005 * This material is provided "as is", with absolutely no warranty expressed 00006 * or implied. Any use is at your own risk. 00007 * 00008 * Permission to use or copy this software for any purpose is hereby granted 00009 * without fee, provided the above notices are retained on all copies. 00010 * Permission to modify the code and to distribute modified code is granted, 00011 * provided the above notices are retained, and a notice that the code was 00012 * modified is included with the above copyright notice. 00013 * 00014 */ 00015 00016 /* NOTE: This is an internal header file, included by other STL headers. 00017 * You should not attempt to use it directly. 00018 */ 00019 00020 #ifndef _STLP_SPECIALIZED_VECTOR_H 00021 #define _STLP_SPECIALIZED_VECTOR_H 00022 00023 #ifndef _STLP_POINTERS_SPEC_TOOLS_H 00024 # include <stl/pointers/_tools.h> 00025 #endif 00026 00027 _STLP_BEGIN_NAMESPACE 00028 00029 #define VECTOR_IMPL _STLP_PTR_IMPL_NAME(vector) 00030 00031 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00032 _STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV _Vector_base<void*,allocator<void*> >; 00033 _STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV VECTOR_IMPL<void*, allocator<void*> >; 00034 #endif 00035 00036 #if defined (_STLP_DEBUG) 00037 # define vector _STLP_NON_DBG_NAME(vector) 00038 _STLP_MOVE_TO_PRIV_NAMESPACE 00039 #endif 00040 00041 template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) > 00042 class vector 00043 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector) 00044 : public __stlport_class<vector<_Tp, _Alloc> > 00045 #endif 00046 { 00047 /* In the vector implementation iterators are pointer which give a number 00048 * of opportunities for optimization. To not break those optimizations 00049 * iterators passed to template should not be wrapped for casting purpose. 00050 * So vector implementation will always use a qualified void pointer type and 00051 * won't use iterator wrapping. 00052 */ 00053 typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_QualifiedType _StorageType; 00054 typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc; 00055 typedef _STLP_PRIV VECTOR_IMPL<_StorageType, _StorageTypeAlloc> _Base; 00056 typedef vector<_Tp, _Alloc> _Self; 00057 00058 typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits; 00059 00060 public: 00061 typedef _Tp value_type; 00062 typedef value_type* pointer; 00063 typedef const value_type* const_pointer; 00064 typedef value_type* iterator; 00065 typedef const value_type* const_iterator; 00066 typedef value_type& reference; 00067 typedef const value_type& const_reference; 00068 typedef size_t size_type; 00069 typedef ptrdiff_t difference_type; 00070 typedef random_access_iterator_tag _Iterator_category; 00071 00072 _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; 00073 _STLP_FORCE_ALLOCATORS(value_type, _Alloc) 00074 typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type; 00075 00076 allocator_type get_allocator() const 00077 { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); } 00078 00079 iterator begin() { return cast_traits::to_value_type_ptr(_M_impl.begin()); } 00080 const_iterator begin() const { return cast_traits::to_value_type_cptr(_M_impl.begin()); } 00081 iterator end() { return cast_traits::to_value_type_ptr(_M_impl.end()); } 00082 const_iterator end() const { return cast_traits::to_value_type_cptr(_M_impl.end()); } 00083 00084 reverse_iterator rbegin() { return reverse_iterator(end()); } 00085 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } 00086 reverse_iterator rend() { return reverse_iterator(begin()); } 00087 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } 00088 00089 size_type size() const { return _M_impl.size(); } 00090 size_type max_size() const { return _M_impl.max_size(); } 00091 00092 size_type capacity() const { return _M_impl.capacity(); } 00093 bool empty() const { return _M_impl.empty(); } 00094 00095 reference operator[](size_type __n) { return cast_traits::to_value_type_ref(_M_impl[__n]); } 00096 const_reference operator[](size_type __n) const { return cast_traits::to_value_type_cref(_M_impl[__n]); } 00097 00098 reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); } 00099 const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); } 00100 reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); } 00101 const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); } 00102 00103 reference at(size_type __n) { return cast_traits::to_value_type_ref(_M_impl.at(__n)); } 00104 const_reference at(size_type __n) const { return cast_traits::to_value_type_cref(_M_impl.at(__n)); } 00105 00106 explicit vector(const allocator_type& __a = allocator_type()) 00107 : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00108 00109 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) 00110 explicit vector(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type), 00111 #else 00112 vector(size_type __n, const value_type& __val, 00113 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ 00114 const allocator_type& __a = allocator_type()) 00115 : _M_impl(__n, cast_traits::to_storage_type_cref(__val), 00116 _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00117 00118 #if defined(_STLP_DONT_SUP_DFLT_PARAM) 00119 explicit vector(size_type __n) 00120 : _M_impl(__n, allocator_type() ) {} 00121 #endif 00122 00123 vector(const _Self& __x) 00124 : _M_impl(__x._M_impl) {} 00125 00126 #if !defined (_STLP_NO_MOVE_SEMANTIC) 00127 explicit vector(__move_source<_Self> src) 00128 : _M_impl(__move_source<_Base>(src.get()._M_impl)) {} 00129 #endif 00130 00131 #if defined (_STLP_MEMBER_TEMPLATES) 00132 template <class _InputIterator> 00133 vector(_InputIterator __first, _InputIterator __last, 00134 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL ) 00135 : _M_impl(__first, __last, 00136 _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00137 00138 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) 00139 template <class _InputIterator> 00140 vector(_InputIterator __first, _InputIterator __last) 00141 : _M_impl(__first, __last) {} 00142 # endif 00143 00144 #else 00145 vector(const_iterator __first, const_iterator __last, 00146 const allocator_type& __a = allocator_type()) 00147 : _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last), 00148 _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00149 #endif /* _STLP_MEMBER_TEMPLATES */ 00150 00151 _Self& operator=(const _Self& __x) { _M_impl = __x._M_impl; return *this; } 00152 00153 void reserve(size_type __n) {_M_impl.reserve(__n);} 00154 void assign(size_type __n, const value_type& __val) 00155 { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); } 00156 00157 #if defined (_STLP_MEMBER_TEMPLATES) 00158 template <class _InputIterator> 00159 void assign(_InputIterator __first, _InputIterator __last) 00160 { _M_impl.assign(__first, __last); } 00161 #else 00162 void assign(const_iterator __first, const_iterator __last) { 00163 _M_impl.assign(cast_traits::to_storage_type_cptr(__first), 00164 cast_traits::to_storage_type_cptr(__last)); 00165 } 00166 #endif /* _STLP_MEMBER_TEMPLATES */ 00167 00168 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) 00169 void push_back(const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) 00170 #else 00171 void push_back(const value_type& __x) 00172 #endif 00173 { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); } 00174 00175 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) 00176 iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) 00177 #else 00178 iterator insert(iterator __pos, const value_type& __x) 00179 #endif 00180 { return cast_traits::to_value_type_ptr(_M_impl.insert(cast_traits::to_storage_type_ptr(__pos), 00181 cast_traits::to_storage_type_cref(__x))); } 00182 00183 #if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) 00184 void push_back() { _M_impl.push_back(); } 00185 iterator insert(iterator __pos) 00186 { return _M_impl.insert(cast_traits::to_storage_type_ptr(__pos)); } 00187 #endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ 00188 00189 void swap(_Self& __x) { _M_impl.swap(__x._M_impl); } 00190 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 00191 void _M_swap_workaround(_Self& __x) { swap(__x); } 00192 #endif 00193 00194 #if defined (_STLP_MEMBER_TEMPLATES) 00195 template <class _InputIterator> 00196 void insert(iterator __pos, _InputIterator __first, _InputIterator __last) 00197 { _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __first, __last); } 00198 #else 00199 void insert(iterator __pos, const_iterator __first, const_iterator __last) { 00200 _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), cast_traits::to_storage_type_cptr(__first), 00201 cast_traits::to_storage_type_cptr(__last)); 00202 } 00203 #endif 00204 00205 void insert (iterator __pos, size_type __n, const value_type& __x) { 00206 _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __n, cast_traits::to_storage_type_cref(__x)); 00207 } 00208 00209 void pop_back() {_M_impl.pop_back();} 00210 iterator erase(iterator __pos) 00211 {return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__pos)));} 00212 iterator erase(iterator __first, iterator __last) { 00213 return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__first), 00214 cast_traits::to_storage_type_ptr(__last))); 00215 } 00216 00217 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) 00218 void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) 00219 #else 00220 void resize(size_type __new_size, const value_type& __x) 00221 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ 00222 { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); } 00223 00224 #if defined(_STLP_DONT_SUP_DFLT_PARAM) 00225 void resize(size_type __new_size) { _M_impl.resize(__new_size); } 00226 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ 00227 00228 void clear() { _M_impl.clear(); } 00229 00230 private: 00231 _Base _M_impl; 00232 }; 00233 00234 #if defined (vector) 00235 # undef vector 00236 _STLP_MOVE_TO_STD_NAMESPACE 00237 #endif 00238 00239 #undef VECTOR_IMPL 00240 00241 _STLP_END_NAMESPACE 00242 00243 #endif /* _STLP_SPECIALIZED_VECTOR_H */ Generated on Thu May 24 2012 04:30:25 for ReactOS by
1.7.6.1
|