]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/vector.h
put wxURI under networking group, next to wxURL
[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
664e5ff9
VZ
67 /**
68 Constructor initializing the vector with the given number of
69 default-constructed objects.
70 */
71 wxVector(size_type size);
72
73 /**
74 Constructor initializing the vector with the given number of
75 copies of the given object.
76 */
77 wxVector(size_type size, const value_type& value);
78
f016d3b4
VS
79 /**
80 Copy onstructor.
81 */
82 wxVector(const wxVector<T>& c);
23324ae1
FM
83
84 /**
85 Destructor.
86 */
f016d3b4
VS
87 ~wxVector();
88
89 /**
09ad05fa 90 Returns item at position @a idx.
f016d3b4
VS
91 */
92 const value_type& at(size_type idx) const;
23324ae1 93
23324ae1 94 /**
09ad05fa 95 Returns item at position @a idx.
23324ae1 96 */
f016d3b4 97 value_type& at(size_type idx);
23324ae1 98
23324ae1 99 /**
f016d3b4 100 Return the last item.
23324ae1 101 */
f016d3b4
VS
102 const value_type& back() const;
103
104 /**
105 Return the last item.
106 */
107 value_type& back();
108
109 /**
110 Return iterator to beginning of the vector.
111 */
112 const_iterator begin() const;
23324ae1 113
23324ae1
FM
114 /**
115 Return iterator to beginning of the vector.
116 */
f016d3b4 117 iterator begin();
23324ae1 118
946954d3
RR
119 /**
120 Return reverse iterator to end of the vector.
121 */
122 reverse_iterator rbegin();
123
124 /**
125 Return reverse iterator to beginning of the vector.
126 */
127 reverse_iterator rend();
128
129
23324ae1 130 /**
f016d3b4 131 Returns vector's current capacity, i.e. how much memory is allocated.
3c4f71cc 132
f016d3b4 133 @see reserve()
23324ae1 134 */
328f5751 135 size_type capacity() const;
23324ae1
FM
136
137 /**
138 Clears the vector.
139 */
140 void clear();
141
142 /**
143 Returns @true if the vector is empty.
144 */
328f5751 145 bool empty() const;
23324ae1 146
23324ae1
FM
147 /**
148 Returns iterator to the end of the vector.
149 */
f016d3b4
VS
150 const_iterator end() const;
151
152 /**
153 Returns iterator to the end of the vector.
154 */
155 iterator end();
23324ae1 156
23324ae1 157 /**
f016d3b4
VS
158 Erase item pointed to by iterator @a it.
159
160 @return Iterator pointing to the item immediately after the erased one.
23324ae1
FM
161 */
162 iterator erase(iterator it);
f016d3b4
VS
163
164 /**
165 Erase items in the range @a first to @a last (@a last is not erased).
166
09ad05fa
BP
167 @return Iterator pointing to the item immediately after the erased
168 range.
f016d3b4 169 */
7c913512 170 iterator erase(iterator first, iterator last);
23324ae1 171
23324ae1 172 /**
f016d3b4 173 Returns the first item.
23324ae1 174 */
f016d3b4 175 const value_type& front() const;
23324ae1
FM
176
177 /**
f016d3b4 178 Returns the first item.
23324ae1 179 */
f016d3b4
VS
180 value_type& front();
181
182 /**
183 Insert item @a v at given position @a it.
184
185 @return Iterator for the inserted item.
186 */
187 iterator insert(iterator it, const value_type& v = value_type());
23324ae1
FM
188
189 /**
190 Assignment operator.
191 */
09ad05fa 192 wxVector& operator=(const wxVector& vb);
23324ae1 193
23324ae1 194 /**
09ad05fa 195 Returns item at position @a idx.
23324ae1 196 */
f016d3b4
VS
197 const value_type& operator[](size_type idx) const;
198
199 /**
09ad05fa 200 Returns item at position @a idx.
f016d3b4
VS
201 */
202 value_type& operator[](size_type idx);
23324ae1
FM
203
204 /**
205 Removes the last item.
206 */
207 void pop_back();
208
209 /**
210 Adds an item to the end of the vector.
211 */
212 void push_back(const value_type& v);
213
214 /**
f016d3b4
VS
215 Reserves memory for at least @a n items.
216
217 @see capacity()
23324ae1
FM
218 */
219 void reserve(size_type n);
09ad05fa
BP
220
221 /**
222 Returns the size of the vector.
223 */
224 size_type size() const;
23324ae1 225};
e54c96f1 226