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