]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/vector.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxVector<T>
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 wxVector<T> is a template class which implements most of the @c std::vector
12 class and can be used like it.
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".
18 Please refer to the STL documentation for further information.
23 @see @ref overview_container, wxList<T>, wxArray<T>, wxVectorSort<T>
29 typedef size_t size_type
;
30 typedef size_t difference_type
;
32 typedef value_type
* pointer
;
33 typedef value_type
* iterator
;
34 typedef const value_type
* const_iterator
;
35 typedef value_type
& reference
;
38 Reverse iterator interface
40 class 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;
68 Constructor initializing the vector with the given number of
69 default-constructed objects.
71 wxVector(size_type size
);
74 Constructor initializing the vector with the given number of
75 copies of the given object.
77 wxVector(size_type size
, const value_type
& value
);
82 wxVector(const wxVector
<T
>& c
);
90 Returns item at position @a idx.
92 const value_type
& at(size_type idx
) const;
95 Returns item at position @a idx.
97 value_type
& at(size_type idx
);
100 Return the last item.
102 const value_type
& back() const;
105 Return the last item.
110 Return iterator to beginning of the vector.
112 const_iterator
begin() const;
115 Return iterator to beginning of the vector.
120 Return reverse iterator to end of the vector.
122 reverse_iterator
rbegin();
125 Return reverse iterator to beginning of the vector.
127 reverse_iterator
rend();
131 Returns vector's current capacity, i.e. how much memory is allocated.
135 size_type
capacity() const;
143 Returns @true if the vector is empty.
148 Returns iterator to the end of the vector.
150 const_iterator
end() const;
153 Returns iterator to the end of the vector.
158 Erase item pointed to by iterator @a it.
160 @return Iterator pointing to the item immediately after the erased one.
162 iterator
erase(iterator it
);
165 Erase items in the range @a first to @a last (@a last is not erased).
167 @return Iterator pointing to the item immediately after the erased
170 iterator
erase(iterator first
, iterator last
);
173 Returns the first item.
175 const value_type
& front() const;
178 Returns the first item.
183 Insert item @a v at given position @a it.
185 @return Iterator for the inserted item.
187 iterator
insert(iterator it
, const value_type
& v
= value_type());
192 wxVector
& operator=(const wxVector
& vb
);
195 Returns item at position @a idx.
197 const value_type
& operator[](size_type idx
) const;
200 Returns item at position @a idx.
202 value_type
& operator[](size_type idx
);
205 Removes the last item.
210 Adds an item to the end of the vector.
212 void push_back(const value_type
& v
);
215 Reserves memory for at least @a n items.
219 void reserve(size_type n
);
222 Makes the vector of size @a n.
224 If @a n is less than the current size(), the elements at the end of the
225 vector are erased. If it is greater, then the vector is completed with
226 either the copies of the given object @a v or @c value_type() objects
227 until it becomes of size @a n.
230 void resize(size_type n
);
231 void resize(size_type n
, const value_type
& v
);
235 Returns the size of the vector.
237 size_type
size() const;
242 Sort the contents of a @c wxVector<T>. In a STL build this function will
243 be defined as a thin wrapper around std::sort. To be sortable the
244 contained type must support the less-than operator.
247 wxVector<SomeClass> v;
248 ... // items are added to the vector v...
255 void wxVectorSort(wxVector
<T
>& v
);