]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/vector.h
Cleanup of wxSocket::_Wait():
[wxWidgets.git] / interface / wx / vector.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: vector.h
e54c96f1 3// Purpose: interface of wxVector<T>
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
7c913512 10
f016d3b4
VS
11 wxVector<T> is a template class which implements most of the @c std::vector
12 class and can be used like it.
7c913512 13
09ad05fa
BP
14 If wxWidgets is compiled in STL mode, wxVector will just be a typedef to
15 @c std::vector. Just like for @c std::vector, objects stored in wxVector<T>
16 need to be @e assignable but don't have to be @e "default constructible".
f016d3b4
VS
17
18 Please refer to the STL documentation for further information.
7c913512 19
e18e78a7 20 @nolibrary
f016d3b4 21 @category{containers}
7c913512 22
09ad05fa 23 @see @ref overview_container, wxList<T>, wxArray<T>
23324ae1 24*/
f016d3b4 25template<typename T>
7c913512 26class wxVector<T>
23324ae1
FM
27{
28public:
f016d3b4 29 typedef size_t size_type;
946954d3 30 typedef size_t difference_type;
f016d3b4 31 typedef T value_type;
946954d3 32 typedef value_type* pointer;
f016d3b4
VS
33 typedef value_type* iterator;
34 typedef const value_type* const_iterator;
35 typedef value_type& reference;
36
946954d3
RR
37 /**
38 Reverse iterator interface
39 */
40 class reverse_iterator
41 {
42 public:
43 reverse_iterator();
44 explicit reverse_iterator(iterator it);
45 reverse_iterator(const reverse_iterator& it);
46 reference operator*() const;
47 pointer operator->() const;
48 iterator base() const;
49 reverse_iterator& operator++();
50 reverse_iterator operator++(int);
51 reverse_iterator& operator--();
52 reverse_iterator operator--(int);
53 reverse_iterator operator+(difference_type n) const;
54 reverse_iterator& operator+=(difference_type n);
55 reverse_iterator operator-(difference_type n) const;
56 reverse_iterator& operator-=(difference_type n);
57 reference operator[](difference_type n) const;
58 bool operator ==(const reverse_iterator& it) const;
59 bool operator !=(const reverse_iterator& it) const;
60 };
61
23324ae1
FM
62 /**
63 Constructor.
64 */
f016d3b4
VS
65 wxVector();
66
67 /**
68 Copy onstructor.
69 */
70 wxVector(const wxVector<T>& c);
23324ae1
FM
71
72 /**
73 Destructor.
74 */
f016d3b4
VS
75 ~wxVector();
76
77 /**
09ad05fa 78 Returns item at position @a idx.
f016d3b4
VS
79 */
80 const value_type& at(size_type idx) const;
23324ae1 81
23324ae1 82 /**
09ad05fa 83 Returns item at position @a idx.
23324ae1 84 */
f016d3b4 85 value_type& at(size_type idx);
23324ae1 86
23324ae1 87 /**
f016d3b4 88 Return the last item.
23324ae1 89 */
f016d3b4
VS
90 const value_type& back() const;
91
92 /**
93 Return the last item.
94 */
95 value_type& back();
96
97 /**
98 Return iterator to beginning of the vector.
99 */
100 const_iterator begin() const;
23324ae1 101
23324ae1
FM
102 /**
103 Return iterator to beginning of the vector.
104 */
f016d3b4 105 iterator begin();
23324ae1 106
946954d3
RR
107 /**
108 Return reverse iterator to end of the vector.
109 */
110 reverse_iterator rbegin();
111
112 /**
113 Return reverse iterator to beginning of the vector.
114 */
115 reverse_iterator rend();
116
117
23324ae1 118 /**
f016d3b4 119 Returns vector's current capacity, i.e. how much memory is allocated.
3c4f71cc 120
f016d3b4 121 @see reserve()
23324ae1 122 */
328f5751 123 size_type capacity() const;
23324ae1
FM
124
125 /**
126 Clears the vector.
127 */
128 void clear();
129
130 /**
131 Returns @true if the vector is empty.
132 */
328f5751 133 bool empty() const;
23324ae1 134
23324ae1
FM
135 /**
136 Returns iterator to the end of the vector.
137 */
f016d3b4
VS
138 const_iterator end() const;
139
140 /**
141 Returns iterator to the end of the vector.
142 */
143 iterator end();
23324ae1 144
23324ae1 145 /**
f016d3b4
VS
146 Erase item pointed to by iterator @a it.
147
148 @return Iterator pointing to the item immediately after the erased one.
23324ae1
FM
149 */
150 iterator erase(iterator it);
f016d3b4
VS
151
152 /**
153 Erase items in the range @a first to @a last (@a last is not erased).
154
09ad05fa
BP
155 @return Iterator pointing to the item immediately after the erased
156 range.
f016d3b4 157 */
7c913512 158 iterator erase(iterator first, iterator last);
23324ae1 159
23324ae1 160 /**
f016d3b4 161 Returns the first item.
23324ae1 162 */
f016d3b4 163 const value_type& front() const;
23324ae1
FM
164
165 /**
f016d3b4 166 Returns the first item.
23324ae1 167 */
f016d3b4
VS
168 value_type& front();
169
170 /**
171 Insert item @a v at given position @a it.
172
173 @return Iterator for the inserted item.
174 */
175 iterator insert(iterator it, const value_type& v = value_type());
23324ae1
FM
176
177 /**
178 Assignment operator.
179 */
09ad05fa 180 wxVector& operator=(const wxVector& vb);
23324ae1 181
23324ae1 182 /**
09ad05fa 183 Returns item at position @a idx.
23324ae1 184 */
f016d3b4
VS
185 const value_type& operator[](size_type idx) const;
186
187 /**
09ad05fa 188 Returns item at position @a idx.
f016d3b4
VS
189 */
190 value_type& operator[](size_type idx);
23324ae1
FM
191
192 /**
193 Removes the last item.
194 */
195 void pop_back();
196
197 /**
198 Adds an item to the end of the vector.
199 */
200 void push_back(const value_type& v);
201
202 /**
f016d3b4
VS
203 Reserves memory for at least @a n items.
204
205 @see capacity()
23324ae1
FM
206 */
207 void reserve(size_type n);
09ad05fa
BP
208
209 /**
210 Returns the size of the vector.
211 */
212 size_type size() const;
23324ae1 213};
e54c96f1 214