]>
Commit | Line | Data |
---|---|---|
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 | 25 | template<typename T> |
7c913512 | 26 | class wxVector<T> |
23324ae1 FM |
27 | { |
28 | public: | |
f016d3b4 VS |
29 | typedef size_t size_type; |
30 | typedef T value_type; | |
31 | typedef value_type* iterator; | |
32 | typedef const value_type* const_iterator; | |
33 | typedef value_type& reference; | |
34 | ||
23324ae1 FM |
35 | /** |
36 | Constructor. | |
37 | */ | |
f016d3b4 VS |
38 | wxVector(); |
39 | ||
40 | /** | |
41 | Copy onstructor. | |
42 | */ | |
43 | wxVector(const wxVector<T>& c); | |
23324ae1 FM |
44 | |
45 | /** | |
46 | Destructor. | |
47 | */ | |
f016d3b4 VS |
48 | ~wxVector(); |
49 | ||
50 | /** | |
09ad05fa | 51 | Returns item at position @a idx. |
f016d3b4 VS |
52 | */ |
53 | const value_type& at(size_type idx) const; | |
23324ae1 | 54 | |
23324ae1 | 55 | /** |
09ad05fa | 56 | Returns item at position @a idx. |
23324ae1 | 57 | */ |
f016d3b4 | 58 | value_type& at(size_type idx); |
23324ae1 | 59 | |
23324ae1 | 60 | /** |
f016d3b4 | 61 | Return the last item. |
23324ae1 | 62 | */ |
f016d3b4 VS |
63 | const value_type& back() const; |
64 | ||
65 | /** | |
66 | Return the last item. | |
67 | */ | |
68 | value_type& back(); | |
69 | ||
70 | /** | |
71 | Return iterator to beginning of the vector. | |
72 | */ | |
73 | const_iterator begin() const; | |
23324ae1 | 74 | |
23324ae1 FM |
75 | /** |
76 | Return iterator to beginning of the vector. | |
77 | */ | |
f016d3b4 | 78 | iterator begin(); |
23324ae1 FM |
79 | |
80 | /** | |
f016d3b4 | 81 | Returns vector's current capacity, i.e. how much memory is allocated. |
3c4f71cc | 82 | |
f016d3b4 | 83 | @see reserve() |
23324ae1 | 84 | */ |
328f5751 | 85 | size_type capacity() const; |
23324ae1 FM |
86 | |
87 | /** | |
88 | Clears the vector. | |
89 | */ | |
90 | void clear(); | |
91 | ||
92 | /** | |
93 | Returns @true if the vector is empty. | |
94 | */ | |
328f5751 | 95 | bool empty() const; |
23324ae1 | 96 | |
23324ae1 FM |
97 | /** |
98 | Returns iterator to the end of the vector. | |
99 | */ | |
f016d3b4 VS |
100 | const_iterator end() const; |
101 | ||
102 | /** | |
103 | Returns iterator to the end of the vector. | |
104 | */ | |
105 | iterator end(); | |
23324ae1 | 106 | |
23324ae1 | 107 | /** |
f016d3b4 VS |
108 | Erase item pointed to by iterator @a it. |
109 | ||
110 | @return Iterator pointing to the item immediately after the erased one. | |
23324ae1 FM |
111 | */ |
112 | iterator erase(iterator it); | |
f016d3b4 VS |
113 | |
114 | /** | |
115 | Erase items in the range @a first to @a last (@a last is not erased). | |
116 | ||
09ad05fa BP |
117 | @return Iterator pointing to the item immediately after the erased |
118 | range. | |
f016d3b4 | 119 | */ |
7c913512 | 120 | iterator erase(iterator first, iterator last); |
23324ae1 | 121 | |
23324ae1 | 122 | /** |
f016d3b4 | 123 | Returns the first item. |
23324ae1 | 124 | */ |
f016d3b4 | 125 | const value_type& front() const; |
23324ae1 FM |
126 | |
127 | /** | |
f016d3b4 | 128 | Returns the first item. |
23324ae1 | 129 | */ |
f016d3b4 VS |
130 | value_type& front(); |
131 | ||
132 | /** | |
133 | Insert item @a v at given position @a it. | |
134 | ||
135 | @return Iterator for the inserted item. | |
136 | */ | |
137 | iterator insert(iterator it, const value_type& v = value_type()); | |
23324ae1 FM |
138 | |
139 | /** | |
140 | Assignment operator. | |
141 | */ | |
09ad05fa | 142 | wxVector& operator=(const wxVector& vb); |
23324ae1 | 143 | |
23324ae1 | 144 | /** |
09ad05fa | 145 | Returns item at position @a idx. |
23324ae1 | 146 | */ |
f016d3b4 VS |
147 | const value_type& operator[](size_type idx) const; |
148 | ||
149 | /** | |
09ad05fa | 150 | Returns item at position @a idx. |
f016d3b4 VS |
151 | */ |
152 | value_type& operator[](size_type idx); | |
23324ae1 FM |
153 | |
154 | /** | |
155 | Removes the last item. | |
156 | */ | |
157 | void pop_back(); | |
158 | ||
159 | /** | |
160 | Adds an item to the end of the vector. | |
161 | */ | |
162 | void push_back(const value_type& v); | |
163 | ||
164 | /** | |
f016d3b4 VS |
165 | Reserves memory for at least @a n items. |
166 | ||
167 | @see capacity() | |
23324ae1 FM |
168 | */ |
169 | void reserve(size_type n); | |
09ad05fa BP |
170 | |
171 | /** | |
172 | Returns the size of the vector. | |
173 | */ | |
174 | size_type size() const; | |
23324ae1 | 175 | }; |
e54c96f1 | 176 |