1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qptrvector.doc:41 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QPtrVector Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPtrVector Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QPtrVector class is a template collection class that
|
---|
35 | provides a vector (array).
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qptrvector-h.html">qptrvector.h</a>></tt>
|
---|
38 | <p>Inherits <a href="qptrcollection.html">QPtrCollection</a>.
|
---|
39 | <p><a href="qptrvector-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QPtrVector"><b>QPtrVector</b></a> ()</li>
|
---|
43 | <li class=fn><a href="#QPtrVector-2"><b>QPtrVector</b></a> ( uint size )</li>
|
---|
44 | <li class=fn><a href="#QPtrVector-3"><b>QPtrVector</b></a> ( const QPtrVector<type> & v )</li>
|
---|
45 | <li class=fn><a href="#~QPtrVector"><b>~QPtrVector</b></a> ()</li>
|
---|
46 | <li class=fn>QPtrVector<type> & <a href="#operator-eq"><b>operator=</b></a> ( const QPtrVector<type> & v )</li>
|
---|
47 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QPtrVector<type> & v ) const</li>
|
---|
48 | <li class=fn>type ** <a href="#data"><b>data</b></a> () const</li>
|
---|
49 | <li class=fn>uint <a href="#size"><b>size</b></a> () const</li>
|
---|
50 | <li class=fn>virtual uint <a href="#count"><b>count</b></a> () const</li>
|
---|
51 | <li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
|
---|
52 | <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
|
---|
53 | <li class=fn>bool <a href="#resize"><b>resize</b></a> ( uint size )</li>
|
---|
54 | <li class=fn>bool <a href="#insert"><b>insert</b></a> ( uint i, const type * d )</li>
|
---|
55 | <li class=fn>bool <a href="#remove"><b>remove</b></a> ( uint i )</li>
|
---|
56 | <li class=fn>type * <a href="#take"><b>take</b></a> ( uint i )</li>
|
---|
57 | <li class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</li>
|
---|
58 | <li class=fn>bool <a href="#fill"><b>fill</b></a> ( const type * d, int size = -1 )</li>
|
---|
59 | <li class=fn>void <a href="#sort"><b>sort</b></a> ()</li>
|
---|
60 | <li class=fn>int <a href="#bsearch"><b>bsearch</b></a> ( const type * d ) const</li>
|
---|
61 | <li class=fn>int <a href="#findRef"><b>findRef</b></a> ( const type * d, uint i = 0 ) const</li>
|
---|
62 | <li class=fn>int <a href="#find"><b>find</b></a> ( const type * d, uint i = 0 ) const</li>
|
---|
63 | <li class=fn>uint <a href="#containsRef"><b>containsRef</b></a> ( const type * d ) const</li>
|
---|
64 | <li class=fn>uint <a href="#contains"><b>contains</b></a> ( const type * d ) const</li>
|
---|
65 | <li class=fn>type * <a href="#operator[]"><b>operator[]</b></a> ( int i ) const</li>
|
---|
66 | <li class=fn>type * <a href="#at"><b>at</b></a> ( uint i ) const</li>
|
---|
67 | </ul>
|
---|
68 | <h2>Important Inherited Members</h2>
|
---|
69 | <ul>
|
---|
70 | <li class=fn>bool <a href="#autoDelete"><b>autoDelete</b></a> () const</li>
|
---|
71 | <li class=fn>void <a href="#setAutoDelete"><b>setAutoDelete</b></a> ( bool enable )</li>
|
---|
72 | </ul>
|
---|
73 | <h2>Protected Members</h2>
|
---|
74 | <ul>
|
---|
75 | <li class=fn>virtual int <a href="#compareItems"><b>compareItems</b></a> ( QPtrCollection::Item d1, QPtrCollection::Item d2 )</li>
|
---|
76 | <li class=fn>virtual QDataStream & <a href="#read"><b>read</b></a> ( QDataStream & s, QPtrCollection::Item & item )</li>
|
---|
77 | <li class=fn>virtual QDataStream & <a href="#write"><b>write</b></a> ( QDataStream & s, QPtrCollection::Item item ) const</li>
|
---|
78 | </ul>
|
---|
79 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
80 |
|
---|
81 |
|
---|
82 | The QPtrVector class is a template collection class that
|
---|
83 | provides a vector (array).
|
---|
84 | <p>
|
---|
85 | <p>
|
---|
86 | <p> <a href="qvaluevector.html">QValueVector</a> is an STL-compatible alternative to this class.
|
---|
87 | <p> QPtrVector is implemented as a template class. Defines a template
|
---|
88 | instance QPtrVector<X> to create a vector that contains pointers
|
---|
89 | to X (X*).
|
---|
90 | <p> A vector is the same as an array. The main difference between
|
---|
91 | QPtrVector and <a href="qmemarray.html">QMemArray</a> is that QPtrVector stores pointers to the
|
---|
92 | elements, whereas QMemArray stores the elements themselves (i.e.
|
---|
93 | QMemArray is value-based and QPtrVector is pointer-based).
|
---|
94 | <p> Items are added to the vector using <a href="#insert">insert</a>() or <a href="#fill">fill</a>(). Items are
|
---|
95 | removed with <a href="#remove">remove</a>(). You can get a pointer to an item at a
|
---|
96 | particular index position using <a href="#at">at</a>().
|
---|
97 | <p> Unless otherwise stated, all functions that remove items from the
|
---|
98 | vector will also delete the element pointed to if <a href="qptrcollection.html#setAutoDelete">auto-deletion</a> is enabled. By default,
|
---|
99 | auto-deletion is disabled; see <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>(). This behaviour can
|
---|
100 | be changed in a subclass by reimplementing the virtual function
|
---|
101 | <a href="qptrcollection.html#deleteItem">deleteItem</a>().
|
---|
102 | <p> Functions that compare items (<a href="#find">find</a>() and <a href="#sort">sort</a>() for example) will
|
---|
103 | do so using the virtual function <a href="#compareItems">compareItems</a>(). The default
|
---|
104 | implementation of this function only compares the pointer values.
|
---|
105 | Reimplement compareItems() in a subclass to get searching and
|
---|
106 | sorting based on the item contents. You can perform a linear
|
---|
107 | search for a pointer in the vector using <a href="#findRef">findRef</a>(), or a binary
|
---|
108 | search (of a sorted vector) using <a href="#bsearch">bsearch</a>(). You can count the
|
---|
109 | number of times an item appears in the vector with <a href="#contains">contains</a>() or
|
---|
110 | <a href="#containsRef">containsRef</a>().
|
---|
111 | <p> <p>See also <a href="qmemarray.html">QMemArray</a> and <a href="tools.html">Non-GUI Classes</a>.
|
---|
112 |
|
---|
113 | <hr><h2>Member Function Documentation</h2>
|
---|
114 | <h3 class=fn><a name="QPtrVector"></a>QPtrVector::QPtrVector ()
|
---|
115 | </h3>
|
---|
116 |
|
---|
117 | <p> Constructs a null vector.
|
---|
118 | <p> <p>See also <a href="#isNull">isNull</a>().
|
---|
119 |
|
---|
120 | <h3 class=fn><a name="QPtrVector-2"></a>QPtrVector::QPtrVector ( uint size )
|
---|
121 | </h3>
|
---|
122 |
|
---|
123 | <p> Constructs an vector with room for <em>size</em> items. Makes a null
|
---|
124 | vector if <em>size</em> == 0.
|
---|
125 | <p> All <em>size</em> positions in the vector are initialized to 0.
|
---|
126 | <p> <p>See also <a href="#size">size</a>(), <a href="#resize">resize</a>(), and <a href="#isNull">isNull</a>().
|
---|
127 |
|
---|
128 | <h3 class=fn><a name="QPtrVector-3"></a>QPtrVector::QPtrVector ( const <a href="qptrvector.html">QPtrVector</a><type> & v )
|
---|
129 | </h3>
|
---|
130 |
|
---|
131 | <p> Constructs a copy of <em>v</em>. Only the pointers are copied (i.e.
|
---|
132 | <a href="shclass.html#shallow-copy">shallow copy</a>).
|
---|
133 |
|
---|
134 | <h3 class=fn><a name="~QPtrVector"></a>QPtrVector::~QPtrVector ()
|
---|
135 | </h3>
|
---|
136 |
|
---|
137 | <p> Removes all items from the vector, and destroys the vector itself.
|
---|
138 | <p> <p>See also <a href="#clear">clear</a>().
|
---|
139 |
|
---|
140 | <h3 class=fn>type * <a name="at"></a>QPtrVector::at ( uint i ) const
|
---|
141 | </h3>
|
---|
142 |
|
---|
143 | <p> Returns the item at position <em>i</em>, or 0 if there is no item at
|
---|
144 | that position. <em>i</em> must be less than <a href="#size">size</a>().
|
---|
145 |
|
---|
146 | <h3 class=fn>bool <a name="autoDelete"></a>QPtrCollection::autoDelete () const
|
---|
147 | </h3>
|
---|
148 |
|
---|
149 | <p> Returns the setting of the auto-delete option. The default is FALSE.
|
---|
150 | <p> <p>See also <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>().
|
---|
151 |
|
---|
152 | <h3 class=fn>int <a name="bsearch"></a>QPtrVector::bsearch ( const type * d ) const
|
---|
153 | </h3>
|
---|
154 |
|
---|
155 | <p> In a sorted array, finds the first occurrence of <em>d</em> using a
|
---|
156 | binary search. For a sorted array, this is generally much faster
|
---|
157 | than <a href="#find">find</a>(), which performs a linear search.
|
---|
158 | <p> Returns the position of <em>d</em>, or -1 if <em>d</em> could not be found. <em>d</em> must not be 0.
|
---|
159 | <p> Compares items using the virtual function <a href="#compareItems">compareItems</a>().
|
---|
160 | <p> <p>See also <a href="#sort">sort</a>() and <a href="#find">find</a>().
|
---|
161 |
|
---|
162 | <h3 class=fn>void <a name="clear"></a>QPtrVector::clear ()<tt> [virtual]</tt>
|
---|
163 | </h3>
|
---|
164 |
|
---|
165 | <p> Removes all items from the vector, and destroys the vector itself.
|
---|
166 | <p> The vector becomes a null vector.
|
---|
167 | <p> <p>See also <a href="#isNull">isNull</a>().
|
---|
168 |
|
---|
169 | <p>Reimplemented from <a href="qptrcollection.html#clear">QPtrCollection</a>.
|
---|
170 | <h3 class=fn>int <a name="compareItems"></a>QPtrVector::compareItems ( <a href="qptrcollection.html#Item">QPtrCollection::Item</a> d1, <a href="qptrcollection.html#Item">QPtrCollection::Item</a> d2 )<tt> [virtual protected]</tt>
|
---|
171 | </h3>
|
---|
172 |
|
---|
173 | <p> This virtual function compares two list items.
|
---|
174 | <p> Returns:
|
---|
175 | <ul>
|
---|
176 | <li> zero if <em>d1</em> == <em>d2</em>
|
---|
177 | <li> nonzero if <em>d1</em> != <em>d2</em>
|
---|
178 | </ul>
|
---|
179 | <p> This function returns <em>int</em> rather than <em>bool</em> so that
|
---|
180 | reimplementations can return one of three values and use it to
|
---|
181 | sort by:
|
---|
182 | <ul>
|
---|
183 | <li> 0 if <em>d1</em> == <em>d2</em>
|
---|
184 | <li> > 0 (positive integer) if <em>d1</em> > <em>d2</em>
|
---|
185 | <li> < 0 (negative integer) if <em>d1</em> < <em>d2</em>
|
---|
186 | </ul>
|
---|
187 | <p> The <a href="#sort">sort</a>() and <a href="#bsearch">bsearch</a>() functions require <a href="#compareItems">compareItems</a>() to be
|
---|
188 | implemented as described here.
|
---|
189 | <p> This function should not modify the vector because some const
|
---|
190 | functions call compareItems().
|
---|
191 |
|
---|
192 | <h3 class=fn>uint <a name="contains"></a>QPtrVector::contains ( const type * d ) const
|
---|
193 | </h3>
|
---|
194 |
|
---|
195 | <p> Returns the number of occurrences of item <em>d</em> in the vector.
|
---|
196 | <p> Compares items using the virtual function <a href="#compareItems">compareItems</a>().
|
---|
197 | <p> <p>See also <a href="#containsRef">containsRef</a>().
|
---|
198 |
|
---|
199 | <h3 class=fn>uint <a name="containsRef"></a>QPtrVector::containsRef ( const type * d ) const
|
---|
200 | </h3>
|
---|
201 |
|
---|
202 | <p> Returns the number of occurrences of the item pointer <em>d</em> in the
|
---|
203 | vector.
|
---|
204 | <p> This function does <em>not</em> use <a href="#compareItems">compareItems</a>() to compare items.
|
---|
205 | <p> <p>See also <a href="#findRef">findRef</a>().
|
---|
206 |
|
---|
207 | <h3 class=fn>uint <a name="count"></a>QPtrVector::count () const<tt> [virtual]</tt>
|
---|
208 | </h3>
|
---|
209 |
|
---|
210 | <p> Returns the number of items in the vector. The vector is empty if
|
---|
211 | <a href="#count">count</a>() == 0.
|
---|
212 | <p> <p>See also <a href="#isEmpty">isEmpty</a>(), <a href="#size">size</a>(), and <a href="#isNull">isNull</a>().
|
---|
213 |
|
---|
214 | <p>Reimplemented from <a href="qptrcollection.html#count">QPtrCollection</a>.
|
---|
215 | <h3 class=fn>type ** <a name="data"></a>QPtrVector::data () const
|
---|
216 | </h3>
|
---|
217 |
|
---|
218 | <p> Returns a pointer to the actual vector data, which is an array of
|
---|
219 | type*.
|
---|
220 | <p> The vector is a null vector if <a href="#data">data</a>() == 0 (null pointer).
|
---|
221 | <p> <p>See also <a href="#isNull">isNull</a>().
|
---|
222 |
|
---|
223 | <h3 class=fn>bool <a name="fill"></a>QPtrVector::fill ( const type * d, int size = -1 )
|
---|
224 | </h3>
|
---|
225 |
|
---|
226 | <p> Inserts item <em>d</em> in all positions in the vector. Any existing
|
---|
227 | items are removed. If <em>d</em> is 0, the vector becomes empty.
|
---|
228 | <p> If <em>size</em> >= 0, the vector is first resized to <em>size</em>. By
|
---|
229 | default, <em>size</em> is -1.
|
---|
230 | <p> Returns TRUE if successful, i.e. <em>size</em> is the same as the
|
---|
231 | current size, or <em>size</em> is larger and the memory has successfully
|
---|
232 | been allocated; otherwise returns FALSE.
|
---|
233 | <p> <p>See also <a href="#resize">resize</a>(), <a href="#insert">insert</a>(), and <a href="#isEmpty">isEmpty</a>().
|
---|
234 |
|
---|
235 | <h3 class=fn>int <a name="find"></a>QPtrVector::find ( const type * d, uint i = 0 ) const
|
---|
236 | </h3>
|
---|
237 |
|
---|
238 | <p> Finds the first occurrence of item <em>d</em> in the vector using a
|
---|
239 | linear search. The search starts at position <em>i</em>, which must be
|
---|
240 | less than <a href="#size">size</a>(). <em>i</em> is by default 0; i.e. the search starts at
|
---|
241 | the start of the vector.
|
---|
242 | <p> Returns the position of <em>d</em>, or -1 if <em>d</em> could not be found.
|
---|
243 | <p> Compares items using the virtual function <a href="#compareItems">compareItems</a>().
|
---|
244 | <p> Use the much faster <a href="#bsearch">bsearch</a>() to search a sorted vector.
|
---|
245 | <p> <p>See also <a href="#findRef">findRef</a>() and <a href="#bsearch">bsearch</a>().
|
---|
246 |
|
---|
247 | <h3 class=fn>int <a name="findRef"></a>QPtrVector::findRef ( const type * d, uint i = 0 ) const
|
---|
248 | </h3>
|
---|
249 |
|
---|
250 | <p> Finds the first occurrence of the item pointer <em>d</em> in the vector
|
---|
251 | using a linear search. The search starts at position <em>i</em>, which
|
---|
252 | must be less than <a href="#size">size</a>(). <em>i</em> is by default 0; i.e. the search
|
---|
253 | starts at the start of the vector.
|
---|
254 | <p> Returns the position of <em>d</em>, or -1 if <em>d</em> could not be found.
|
---|
255 | <p> This function does <em>not</em> use <a href="#compareItems">compareItems</a>() to compare items.
|
---|
256 | <p> Use the much faster <a href="#bsearch">bsearch</a>() to search a sorted vector.
|
---|
257 | <p> <p>See also <a href="#find">find</a>() and <a href="#bsearch">bsearch</a>().
|
---|
258 |
|
---|
259 | <h3 class=fn>bool <a name="insert"></a>QPtrVector::insert ( uint i, const type * d )
|
---|
260 | </h3>
|
---|
261 |
|
---|
262 | <p> Sets position <em>i</em> in the vector to contain the item <em>d</em>. <em>i</em>
|
---|
263 | must be less than <a href="#size">size</a>(). Any previous element in position <em>i</em> is
|
---|
264 | removed.
|
---|
265 | <p> <p>See also <a href="#at">at</a>().
|
---|
266 |
|
---|
267 | <h3 class=fn>bool <a name="isEmpty"></a>QPtrVector::isEmpty () const
|
---|
268 | </h3>
|
---|
269 |
|
---|
270 | <p> Returns TRUE if the vector is empty; otherwise returns FALSE.
|
---|
271 | <p> <p>See also <a href="#count">count</a>().
|
---|
272 |
|
---|
273 | <h3 class=fn>bool <a name="isNull"></a>QPtrVector::isNull () const
|
---|
274 | </h3>
|
---|
275 |
|
---|
276 | <p> Returns TRUE if the vector is null; otherwise returns FALSE.
|
---|
277 | <p> A null vector has <a href="#size">size</a>() == 0 and <a href="#data">data</a>() == 0.
|
---|
278 | <p> <p>See also <a href="#size">size</a>().
|
---|
279 |
|
---|
280 | <h3 class=fn><a href="qptrvector.html">QPtrVector</a><type> & <a name="operator-eq"></a>QPtrVector::operator= ( const <a href="qptrvector.html">QPtrVector</a><type> & v )
|
---|
281 | </h3>
|
---|
282 |
|
---|
283 | <p> Assigns <em>v</em> to this vector and returns a reference to this
|
---|
284 | vector.
|
---|
285 | <p> This vector is first cleared and then all the items from <em>v</em> are
|
---|
286 | copied into the vector. Only the pointers are copied (i.e. <a href="shclass.html#shallow-copy">shallow copy</a>).
|
---|
287 | <p> <p>See also <a href="#clear">clear</a>().
|
---|
288 |
|
---|
289 | <h3 class=fn>bool <a name="operator-eq-eq"></a>QPtrVector::operator== ( const <a href="qptrvector.html">QPtrVector</a><type> & v ) const
|
---|
290 | </h3>
|
---|
291 |
|
---|
292 | <p> Returns TRUE if this vector and <em>v</em> are equal; otherwise returns
|
---|
293 | FALSE.
|
---|
294 |
|
---|
295 | <h3 class=fn>type * <a name="operator[]"></a>QPtrVector::operator[] ( int i ) const
|
---|
296 | </h3>
|
---|
297 |
|
---|
298 | <p> Returns the item at position <em>i</em>, or 0 if there is no item at
|
---|
299 | that position. <em>i</em> must be less than <a href="#size">size</a>().
|
---|
300 | <p> Equivalent to <a href="#at">at</a>( <em>i</em> ).
|
---|
301 | <p> <p>See also <a href="#at">at</a>().
|
---|
302 |
|
---|
303 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="read"></a>QPtrVector::read ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qptrcollection.html#Item">QPtrCollection::Item</a> & item )<tt> [virtual protected]</tt>
|
---|
304 | </h3>
|
---|
305 |
|
---|
306 | <p> Reads a vector item, <em>item</em>, from the stream <em>s</em> and returns a
|
---|
307 | reference to the stream.
|
---|
308 | <p> The default implementation sets <em>item</em> to 0.
|
---|
309 | <p> <p>See also <a href="#write">write</a>().
|
---|
310 |
|
---|
311 | <h3 class=fn>bool <a name="remove"></a>QPtrVector::remove ( uint i )
|
---|
312 | </h3>
|
---|
313 |
|
---|
314 | <p> Removes the item at position <em>i</em> in the vector, if there is one.
|
---|
315 | <em>i</em> must be less than <a href="#size">size</a>().
|
---|
316 | <p> Returns TRUE if <em>i</em> is within range; otherwise returns FALSE.
|
---|
317 | <p> <p>See also <a href="#take">take</a>() and <a href="#at">at</a>().
|
---|
318 |
|
---|
319 | <h3 class=fn>bool <a name="resize"></a>QPtrVector::resize ( uint size )
|
---|
320 | </h3>
|
---|
321 |
|
---|
322 | <p> Resizes (expands or shrinks) the vector to <em>size</em> elements. The
|
---|
323 | vector becomes a null vector if <em>size</em> == 0.
|
---|
324 | <p> Any items at position <em>size</em> or beyond in the vector are removed.
|
---|
325 | New positions are initialized to 0.
|
---|
326 | <p> Returns TRUE if successful, i.e. if the memory was successfully
|
---|
327 | allocated; otherwise returns FALSE.
|
---|
328 | <p> <p>See also <a href="#size">size</a>() and <a href="#isNull">isNull</a>().
|
---|
329 |
|
---|
330 | <h3 class=fn>void <a name="setAutoDelete"></a>QPtrCollection::setAutoDelete ( bool enable )
|
---|
331 | </h3>
|
---|
332 |
|
---|
333 | <p> Sets the collection to auto-delete its contents if <em>enable</em> is
|
---|
334 | TRUE and to never delete them if <em>enable</em> is FALSE.
|
---|
335 | <p> If auto-deleting is turned on, all the items in a collection are
|
---|
336 | deleted when the collection itself is deleted. This is convenient
|
---|
337 | if the collection has the only pointer to the items.
|
---|
338 | <p> The default setting is FALSE, for safety. If you turn it on, be
|
---|
339 | careful about copying the collection - you might find yourself
|
---|
340 | with two collections deleting the same items.
|
---|
341 | <p> Note that the auto-delete setting may also affect other functions
|
---|
342 | in subclasses. For example, a subclass that has a <a href="#remove">remove</a>()
|
---|
343 | function will remove the item from its data structure, and if
|
---|
344 | auto-delete is enabled, will also delete the item.
|
---|
345 | <p> <p>See also <a href="qptrcollection.html#autoDelete">autoDelete</a>().
|
---|
346 |
|
---|
347 | <p>Examples: <a href="grapher-nsplugin-example.html#x2769">grapher/grapher.cpp</a>, <a href="scribble-example.html#x924">scribble/scribble.cpp</a>, and <a href="bigtable-example.html#x1291">table/bigtable/main.cpp</a>.
|
---|
348 | <h3 class=fn>uint <a name="size"></a>QPtrVector::size () const
|
---|
349 | </h3>
|
---|
350 |
|
---|
351 | <p> Returns the size of the vector, i.e. the number of vector
|
---|
352 | positions. This is also the maximum number of items the vector can
|
---|
353 | hold.
|
---|
354 | <p> The vector is a null vector if <a href="#size">size</a>() == 0.
|
---|
355 | <p> <p>See also <a href="#isNull">isNull</a>(), <a href="#resize">resize</a>(), and <a href="#count">count</a>().
|
---|
356 |
|
---|
357 | <h3 class=fn>void <a name="sort"></a>QPtrVector::sort ()
|
---|
358 | </h3>
|
---|
359 |
|
---|
360 | <p> Sorts the items in ascending order. Any empty positions will be
|
---|
361 | put last.
|
---|
362 | <p> Compares items using the virtual function <a href="#compareItems">compareItems</a>().
|
---|
363 | <p> <p>See also <a href="#bsearch">bsearch</a>().
|
---|
364 |
|
---|
365 | <h3 class=fn>type * <a name="take"></a>QPtrVector::take ( uint i )
|
---|
366 | </h3>
|
---|
367 |
|
---|
368 | <p> Returns the item at position <em>i</em> in the vector, and removes that
|
---|
369 | item from the vector. <em>i</em> must be less than <a href="#size">size</a>(). If there is
|
---|
370 | no item at position <em>i</em>, 0 is returned.
|
---|
371 | <p> Unlike <a href="#remove">remove</a>(), this function does <em>not</em> call <a href="qptrcollection.html#deleteItem">deleteItem</a>() for
|
---|
372 | the removed item.
|
---|
373 | <p> <p>See also <a href="#remove">remove</a>() and <a href="#at">at</a>().
|
---|
374 |
|
---|
375 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="write"></a>QPtrVector::write ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qptrcollection.html#Item">QPtrCollection::Item</a> item ) const<tt> [virtual protected]</tt>
|
---|
376 | </h3>
|
---|
377 |
|
---|
378 | <p> Writes a vector item, <em>item</em>, to the stream <em>s</em> and returns a
|
---|
379 | reference to the stream.
|
---|
380 | <p> The default implementation does nothing.
|
---|
381 | <p> <p>See also <a href="#read">read</a>().
|
---|
382 |
|
---|
383 | <!-- eof -->
|
---|
384 | <hr><p>
|
---|
385 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
386 | Copyright © 1995-2007
|
---|
387 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
388 | <table width=100% cellspacing=0 border=0><tr>
|
---|
389 | <td>Copyright © 2007
|
---|
390 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
391 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
392 | </table></div></address></body>
|
---|
393 | </html>
|
---|