ReactOS 0.4.15-dev-7712-gbbbcd8e
_vector.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003
3 * Francois Dumont
4 *
5 * This material is provided "as is", with absolutely no warranty expressed
6 * or implied. Any use is at your own risk.
7 *
8 * Permission to use or copy this software for any purpose is hereby granted
9 * without fee, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
13 *
14 */
15
16/* NOTE: This is an internal header file, included by other STL headers.
17 * You should not attempt to use it directly.
18 */
19
20#ifndef _STLP_SPECIALIZED_VECTOR_H
21#define _STLP_SPECIALIZED_VECTOR_H
22
23#ifndef _STLP_POINTERS_SPEC_TOOLS_H
24# include <stl/pointers/_tools.h>
25#endif
26
28
29#define VECTOR_IMPL _STLP_PTR_IMPL_NAME(vector)
30
31#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
33_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV VECTOR_IMPL<void*, allocator<void*> >;
34#endif
35
36#if defined (_STLP_DEBUG)
37# define vector _STLP_NON_DBG_NAME(vector)
39#endif
40
41template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
42class vector
43#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector)
44 : public __stlport_class<vector<_Tp, _Alloc> >
45#endif
46{
47 /* In the vector implementation iterators are pointer which give a number
48 * of opportunities for optimization. To not break those optimizations
49 * iterators passed to template should not be wrapped for casting purpose.
50 * So vector implementation will always use a qualified void pointer type and
51 * won't use iterator wrapping.
52 */
55 typedef _STLP_PRIV VECTOR_IMPL<_StorageType, _StorageTypeAlloc> _Base;
57
59
60public:
61 typedef _Tp value_type;
63 typedef const value_type* const_pointer;
65 typedef const value_type* const_iterator;
68 typedef size_t size_type;
71
75
77 { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
78
79 iterator begin() { return cast_traits::to_value_type_ptr(_M_impl.begin()); }
80 const_iterator begin() const { return cast_traits::to_value_type_cptr(_M_impl.begin()); }
81 iterator end() { return cast_traits::to_value_type_ptr(_M_impl.end()); }
82 const_iterator end() const { return cast_traits::to_value_type_cptr(_M_impl.end()); }
83
85 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
87 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
88
89 size_type size() const { return _M_impl.size(); }
90 size_type max_size() const { return _M_impl.max_size(); }
91
92 size_type capacity() const { return _M_impl.capacity(); }
93 bool empty() const { return _M_impl.empty(); }
94
95 reference operator[](size_type __n) { return cast_traits::to_value_type_ref(_M_impl[__n]); }
96 const_reference operator[](size_type __n) const { return cast_traits::to_value_type_cref(_M_impl[__n]); }
97
98 reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); }
99 const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); }
100 reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); }
101 const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); }
102
103 reference at(size_type __n) { return cast_traits::to_value_type_ref(_M_impl.at(__n)); }
104 const_reference at(size_type __n) const { return cast_traits::to_value_type_cref(_M_impl.at(__n)); }
105
106 explicit vector(const allocator_type& __a = allocator_type())
108
109#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
111#else
113#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
114 const allocator_type& __a = allocator_type())
115 : _M_impl(__n, cast_traits::to_storage_type_cref(__val),
117
118#if defined(_STLP_DONT_SUP_DFLT_PARAM)
119 explicit vector(size_type __n)
120 : _M_impl(__n, allocator_type() ) {}
121#endif
122
123 vector(const _Self& __x)
124 : _M_impl(__x._M_impl) {}
125
126#if !defined (_STLP_NO_MOVE_SEMANTIC)
129#endif
130
131#if defined (_STLP_MEMBER_TEMPLATES)
132 template <class _InputIterator>
133 vector(_InputIterator __first, _InputIterator __last,
135 : _M_impl(__first, __last,
137
138# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
139 template <class _InputIterator>
140 vector(_InputIterator __first, _InputIterator __last)
141 : _M_impl(__first, __last) {}
142# endif
143
144#else
146 const allocator_type& __a = allocator_type())
147 : _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last),
149#endif /* _STLP_MEMBER_TEMPLATES */
150
151 _Self& operator=(const _Self& __x) { _M_impl = __x._M_impl; return *this; }
152
153 void reserve(size_type __n) {_M_impl.reserve(__n);}
155 { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); }
156
157#if defined (_STLP_MEMBER_TEMPLATES)
158 template <class _InputIterator>
159 void assign(_InputIterator __first, _InputIterator __last)
160 { _M_impl.assign(__first, __last); }
161#else
163 _M_impl.assign(cast_traits::to_storage_type_cptr(__first),
164 cast_traits::to_storage_type_cptr(__last));
165 }
166#endif /* _STLP_MEMBER_TEMPLATES */
167
168#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
170#else
171 void push_back(const value_type& __x)
172#endif
173 { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); }
174
175#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
177#else
178 iterator insert(iterator __pos, const value_type& __x)
179#endif
180 { return cast_traits::to_value_type_ptr(_M_impl.insert(cast_traits::to_storage_type_ptr(__pos),
181 cast_traits::to_storage_type_cref(__x))); }
182
183#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
184 void push_back() { _M_impl.push_back(); }
186 { return _M_impl.insert(cast_traits::to_storage_type_ptr(__pos)); }
187#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
188
189 void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
190#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
191 void _M_swap_workaround(_Self& __x) { swap(__x); }
192#endif
193
194#if defined (_STLP_MEMBER_TEMPLATES)
195 template <class _InputIterator>
196 void insert(iterator __pos, _InputIterator __first, _InputIterator __last)
197 { _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __first, __last); }
198#else
200 _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), cast_traits::to_storage_type_cptr(__first),
201 cast_traits::to_storage_type_cptr(__last));
202 }
203#endif
204
205 void insert (iterator __pos, size_type __n, const value_type& __x) {
206 _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __n, cast_traits::to_storage_type_cref(__x));
207 }
208
209 void pop_back() {_M_impl.pop_back();}
211 {return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__pos)));}
213 return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__first),
214 cast_traits::to_storage_type_ptr(__last)));
215 }
216
217#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
219#else
220 void resize(size_type __new_size, const value_type& __x)
221#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
222 { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); }
223
224#if defined(_STLP_DONT_SUP_DFLT_PARAM)
225 void resize(size_type __new_size) { _M_impl.resize(__new_size); }
226#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
227
228 void clear() { _M_impl.clear(); }
229
230private:
232};
233
234#if defined (vector)
235# undef vector
237#endif
238
239#undef VECTOR_IMPL
240
242
243#endif /* _STLP_SPECIALIZED_VECTOR_H */
#define reverse_iterator
Definition: _abbrevs.h:34
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
return __n
Definition: _algo.h:75
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
#define _STLP_CONVERT_ALLOCATOR(__a, _Tp)
Definition: _alloc.h:183
#define _STLP_FORCE_ALLOCATORS(a, y)
Definition: _alloc.h:436
#define _Alloc
Definition: _bvector.h:330
#define _STLP_DEFAULT_CONSTRUCTED(_TTp)
Definition: _construct.h:265
#define _STLP_PRIV
Definition: _dm.h:70
void get(int argc, const char *argv[])
Definition: cmds.c:480
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
#define _STLP_TYPENAME
Definition: features.h:612
#define _STLP_ALLOCATOR_TYPE_DFL
Definition: features.h:691
#define _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS
Definition: features.h:747
#define _STLP_EXPORT_TEMPLATE_CLASS
Definition: features.h:987
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
char typename[32]
Definition: main.c:84
GLuint GLuint end
Definition: gl.h:1545
GLenum src
Definition: glext.h:6340
if(dx< 0)
Definition: linetemp.h:194
#define swap(a, b)
Definition: qsort.c:63
_Rebind_type::other allocator_type
Definition: _alloc.h:201
__select<!use_const_volatile_void_ptr, _Tp, typename__select< use_void_ptr, void *, typename__select< use_const_void_ptr, constvoid *, typename__select< use_volatile_void_ptr, volatilevoid *, constvolatilevoid * >::_Ret >::_Ret >::_Ret >::_Ret _QualifiedType
Definition: _tools.h:163
iterator erase(iterator __pos)
Definition: _vector.h:210
void pop_back()
Definition: _vector.h:209
iterator end()
Definition: _vector.h:81
const_iterator begin() const
Definition: _vector.h:80
vector(size_type __n, const value_type &__val=_STLP_DEFAULT_CONSTRUCTED(value_type), const allocator_type &__a=allocator_type())
Definition: _vector.h:110
const_iterator end() const
Definition: _vector.h:82
void assign(const_iterator __first, const_iterator __last)
Definition: _vector.h:162
const value_type * const_pointer
Definition: _vector.h:63
void insert(iterator __pos, const_iterator __first, const_iterator __last)
Definition: _vector.h:199
random_access_iterator_tag _Iterator_category
Definition: _vector.h:70
_Self & operator=(const _Self &__x)
Definition: _vector.h:151
vector(const _Self &__x)
Definition: _vector.h:123
reference back()
Definition: _vector.h:100
void insert(iterator __pos, size_type __n, const value_type &__x)
Definition: _vector.h:205
reverse_iterator rbegin()
Definition: _vector.h:84
_Tp value_type
Definition: _vector.h:61
size_type max_size() const
Definition: _vector.h:90
vector(__move_source< _Self > src)
Definition: _vector.h:127
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379
size_type capacity() const
Definition: _vector.h:92
void resize(size_type __new_size, const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:639
value_type * pointer
Definition: _vector.h:62
reference operator[](size_type __n)
Definition: _vector.h:95
reference front()
Definition: _vector.h:98
_Base::allocator_type allocator_type
Definition: _vector.h:119
void push_back(const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _vector.h:169
vector(const allocator_type &__a=allocator_type())
Definition: _vector.h:106
_Base _M_impl
Definition: _vector.h:231
vector(const_iterator __first, const_iterator __last, const allocator_type &__a=allocator_type())
Definition: _vector.h:145
iterator insert(iterator __pos, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _vector.h:176
const_reverse_iterator rend() const
Definition: _vector.h:87
iterator begin()
Definition: _vector.h:79
void swap(_Self &__x)
Definition: _vector.h:189
const_reference front() const
Definition: _vector.h:99
const value_type * const_iterator
Definition: _vector.h:65
size_type size() const
Definition: _vector.h:89
const_reverse_iterator rbegin() const
Definition: _vector.h:85
size_t size_type
Definition: _vector.h:68
allocator_type get_allocator() const
Definition: _vector.h:135
reference at(size_type __n)
Definition: _vector.h:103
reverse_iterator rend()
Definition: _vector.h:86
vector< _Tp, _Alloc > _Self
Definition: _vector.h:56
ptrdiff_t difference_type
Definition: _vector.h:69
bool empty() const
Definition: _vector.h:93
value_type * iterator
Definition: _vector.h:64
value_type & reference
Definition: _vector.h:66
iterator erase(iterator __first, iterator __last)
Definition: _vector.h:212
void clear()
Definition: _vector.h:228
const_reference operator[](size_type __n) const
Definition: _vector.h:96
void assign(size_type __n, const _Tp &__val)
Definition: _vector.h:318
void resize(size_type __new_size, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _vector.h:218
_STLP_PRIV VECTOR_IMPL< _StorageType, _StorageTypeAlloc > _Base
Definition: _vector.h:55
const value_type & const_reference
Definition: _vector.h:67
_Alloc_traits< _StorageType, _Alloc >::allocator_type _StorageTypeAlloc
Definition: _vector.h:54
const_reference at(size_type __n) const
Definition: _vector.h:104
_STLP_TYPENAME _STLP_PRIV _StorageType< _Tp >::_QualifiedType _StorageType
Definition: _vector.h:53
_STLP_PRIV _CastTraits< _StorageType, _Tp > cast_traits
Definition: _vector.h:58
_STLP_PRIV _Vector_base< _Tp, _Alloc > _Base
Definition: _vector.h:115
void reserve(size_type __n)
Definition: _vector.h:153
void assign(size_type __n, const value_type &__val)
Definition: _vector.h:154
const_reference back() const
Definition: _vector.h:101
static clock_t begin
Definition: xmllint.c:458
static int insert
Definition: xmllint.c:138