]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/vector.h
no changes, just reformat, remove extraneous semicolons and inline keywords
[wxWidgets.git] / interface / wx / vector.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: vector.h
3 // Purpose: interface of wxVector<T>
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10
11 wxVector<T> is a template class which implements most of the @c std::vector
12 class and can be used like it.
13
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".
17
18 Please refer to the STL documentation for further information.
19
20 @nolibrary
21 @category{containers}
22
23 @see @ref overview_container, wxList<T>, wxArray<T>
24 */
25 template<typename T>
26 class wxVector<T>
27 {
28 public:
29 typedef size_t size_type;
30 typedef size_t difference_type;
31 typedef T value_type;
32 typedef value_type* pointer;
33 typedef value_type* iterator;
34 typedef const value_type* const_iterator;
35 typedef value_type& reference;
36
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
62 /**
63 Constructor.
64 */
65 wxVector();
66
67 /**
68 Copy onstructor.
69 */
70 wxVector(const wxVector<T>& c);
71
72 /**
73 Destructor.
74 */
75 ~wxVector();
76
77 /**
78 Returns item at position @a idx.
79 */
80 const value_type& at(size_type idx) const;
81
82 /**
83 Returns item at position @a idx.
84 */
85 value_type& at(size_type idx);
86
87 /**
88 Return the last item.
89 */
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;
101
102 /**
103 Return iterator to beginning of the vector.
104 */
105 iterator begin();
106
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
118 /**
119 Returns vector's current capacity, i.e. how much memory is allocated.
120
121 @see reserve()
122 */
123 size_type capacity() const;
124
125 /**
126 Clears the vector.
127 */
128 void clear();
129
130 /**
131 Returns @true if the vector is empty.
132 */
133 bool empty() const;
134
135 /**
136 Returns iterator to the end of the vector.
137 */
138 const_iterator end() const;
139
140 /**
141 Returns iterator to the end of the vector.
142 */
143 iterator end();
144
145 /**
146 Erase item pointed to by iterator @a it.
147
148 @return Iterator pointing to the item immediately after the erased one.
149 */
150 iterator erase(iterator it);
151
152 /**
153 Erase items in the range @a first to @a last (@a last is not erased).
154
155 @return Iterator pointing to the item immediately after the erased
156 range.
157 */
158 iterator erase(iterator first, iterator last);
159
160 /**
161 Returns the first item.
162 */
163 const value_type& front() const;
164
165 /**
166 Returns the first item.
167 */
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());
176
177 /**
178 Assignment operator.
179 */
180 wxVector& operator=(const wxVector& vb);
181
182 /**
183 Returns item at position @a idx.
184 */
185 const value_type& operator[](size_type idx) const;
186
187 /**
188 Returns item at position @a idx.
189 */
190 value_type& operator[](size_type idx);
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 /**
203 Reserves memory for at least @a n items.
204
205 @see capacity()
206 */
207 void reserve(size_type n);
208
209 /**
210 Returns the size of the vector.
211 */
212 size_type size() const;
213 };
214