1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QList Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QList Class Reference</h1><br clear="all">
<p>
The QList class is a template class that provides doubly linked lists.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qlist-h.html">qlist.h</a>></code>
<p>
Inherits <a href="qglist.html">QGList</a>.
<p>Inherited by <a href="qstrlist.html">QStrList</a>.
<p><a href="qlist-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#3082d2"><b>QList</b></a>()</div>
<li><div class="fn"><a href="#6bedfd"><b>QList</b></a>(constQList<type>&list)</div>
<li><div class="fn"><a href="#9f06e0"><b>~QList</b></a>()</div>
<li><div class="fn">QList<type>&<a href="#95ba1b"><b>operator=</b></a>(constQList<type>&list)</div>
<li><div class="fn">bool<a href="#5b7aa9"><b>operator==</b></a>(constQList<type>&list)const</div>
<li><div class="fn">virtualuint<a href="#359d9f"><b>count</b></a>()const</div>
<li><div class="fn">bool<a href="#10b215"><b>isEmpty</b></a>()const</div>
<li><div class="fn">bool<a href="#876f9c"><b>insert</b></a>(uintindex, consttype*item)</div>
<li><div class="fn">void<a href="#bf9354"><b>inSort</b></a>(consttype*item)</div>
<li><div class="fn">void<a href="#ec8a11"><b>prepend</b></a>(consttype*item)</div>
<li><div class="fn">void<a href="#c5746a"><b>append</b></a>(consttype*item)</div>
<li><div class="fn">bool<a href="#c3eaf3"><b>remove</b></a>(uintindex)</div>
<li><div class="fn">bool<a href="#00d619"><b>remove</b></a>()</div>
<li><div class="fn">bool<a href="#165d79"><b>remove</b></a>(consttype*item)</div>
<li><div class="fn">bool<a href="#f3ac41"><b>removeRef</b></a>(consttype*item)</div>
<li><div class="fn">void<a href="#85ecce"><b>removeNode</b></a>(QLNode*node)</div>
<li><div class="fn">bool<a href="#7d8a6f"><b>removeFirst</b></a>()</div>
<li><div class="fn">bool<a href="#a64806"><b>removeLast</b></a>()</div>
<li><div class="fn">type*<a href="#e1f650"><b>take</b></a>(uintindex)</div>
<li><div class="fn">type*<a href="#0639ad"><b>take</b></a>()</div>
<li><div class="fn">type*<a href="#eb9203"><b>takeNode</b></a>(QLNode*node)</div>
<li><div class="fn">virtualvoid<a href="#251773"><b>clear</b></a>()</div>
<li><div class="fn">void<a href="#1ef901"><b>sort</b></a>()</div>
<li><div class="fn">int<a href="#3e1af2"><b>find</b></a>(consttype*item)</div>
<li><div class="fn">int<a href="#493c49"><b>findNext</b></a>(consttype*item)</div>
<li><div class="fn">int<a href="#f15291"><b>findRef</b></a>(consttype*item)</div>
<li><div class="fn">int<a href="#9da100"><b>findNextRef</b></a>(consttype*item)</div>
<li><div class="fn">uint<a href="#b49a60"><b>contains</b></a>(consttype*item)const</div>
<li><div class="fn">uint<a href="#e73287"><b>containsRef</b></a>(consttype*item)const</div>
<li><div class="fn">type*<a href="#1cdd9a"><b>at</b></a>(uintindex)</div>
<li><div class="fn">int<a href="#0e7e42"><b>at</b></a>()const</div>
<li><div class="fn">type*<a href="#3501e8"><b>current</b></a>()const</div>
<li><div class="fn">QLNode*<a href="#ed045c"><b>currentNode</b></a>()const</div>
<li><div class="fn">type*<a href="#e33b29"><b>getFirst</b></a>()const</div>
<li><div class="fn">type*<a href="#4fbf59"><b>getLast</b></a>()const</div>
<li><div class="fn">type*<a href="#e625f9"><b>first</b></a>()</div>
<li><div class="fn">type*<a href="#cb27aa"><b>last</b></a>()</div>
<li><div class="fn">type*<a href="#f95ddd"><b>next</b></a>()</div>
<li><div class="fn">type*<a href="#ace811"><b>prev</b></a>()</div>
<li><div class="fn">void<a href="#df4c31"><b>toVector</b></a>(QGVector*vec)const</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QList class is a template class that provides doubly linked lists.
<p>
In Qt 2.0 QList is only implemented as a template class. Define a
template instance QList<X> to create a list that operates on pointers
to X, or X*.
<p>Example:
<pre> #include <qlist.h>
#include <qstring.h>
#include <stdio.h>
class Employee
{
public:
Employee( const QString& name, int salary ) { n=name; s=salary; }
<a href="qstring.html">QString</a> name() const { return n; }
int salary() const { return s; }
private:
<a href="qstring.html">QString</a> n;
int s;
};
void main()
{
<a href="qlist.html">QList</a><Employee> list; // list of pointers to Employee
list.<a href="qcollection.html#a8ef9f">setAutoDelete</a>( TRUE ); // delete items when they are removed
list.<a href="#c5746a">append</a>( new Employee("Bill", 50000) );
list.<a href="#c5746a">append</a>( new Employee("Steve",80000) );
list.<a href="#c5746a">append</a>( new Employee("Ron", 60000) );
Employee *emp;
for ( emp=list.<a href="#e625f9">first</a>(); emp != 0; emp=list.<a href="#f95ddd">next</a>() )
printf( "%s earns %d\n", emp->name().latin1(), emp->salary() );
}
</pre>
<p>Program output:
<pre> Bill earns 50000
Steve earns 80000
Ron earns 60000
</pre>
<p>The list class is indexable and has a <a href="#0e7e42">current index</a>
and a <a href="#3501e8">current item</a>. The first item corresponds
to index 0. The current index is -1 if the current item is null.
<p>QList has several member functions for traversing the list, but using
a <a href="qlistiterator.html">QListIterator</a> can be more practical. Multiple list iterators may
traverse the same list, independent of each other and independent of
the current list item.
<p>In the example above, we make the call <a href="qcollection.html#a8ef9f">setAutoDelete</a>(TRUE).
Enabling auto-deletion tells the list to delete items that are removed
from the list. The default is to not delete items when they are
removed, but that would cause a memory leak in our example since we have
no other references to the list items.
<p>List items are stored as <code>void*</code> in an internal <a href="qlnode.html">QLNode</a>, which also
holds pointers to the next and previous list items. The functions
<a href="#ed045c">currentNode</a>(), <a href="#85ecce">removeNode</a>() and <a href="#eb9203">takeNode</a>() operate directly on the
QLNode, but they should be used with care.
<p>When inserting an item into a list, only the pointer is copied, not the
item itself. This is called a shallow copy. It is possible to make the
list copy all of the item's data (known as a deep copy) when an item is
inserted. <a href="#876f9c">insert</a>(), <a href="#bf9354">inSort</a>() and <a href="#c5746a">append</a>() call the virtual function
<a href="qcollection.html#55065e">QCollection::newItem</a>() for the item to be inserted.
Inherit a list and reimplement it if you want deep copies.
<p>When removing an item from a list, the virtual function
<a href="qcollection.html#8d78e7">QCollection::deleteItem</a>() is called. QList's default implementation
is to delete the item if auto-deletion is enabled.
<p>The virtual function <a href="qglist.html#f2a675">QGList::compareItems</a>() can be reimplemented to
compare two list items. This function is called from all list functions
that need to compare list items, for instance <a href="#00d619">remove</a>(const type*).
If you only want to deal with pointers, there are functions that
compare pointers instead, for instance <a href="#f3ac41">removeRef</a>(const type*).
These functions are somewhat faster than those that call <a href="qglist.html#f2a675">compareItems</a>().
<p>The <a href="qstrlist.html">QStrList</a> class in <a href="qstrlist-h.html">qstrlist.h</a> is a list of <code>char*.</code> QStrList is
a good example of a list that reimplements <a href="qcollection.html#55065e">newItem</a>(), <a href="qcollection.html#8d78e7">deleteItem</a>() and
compareItems()
<p>See also <a href="qlistiterator.html">QListIterator</a> and <a href="collection.html">Collection Classes</a>
<p>Examples:
<a href="grapher-grapher-cpp.html#QList">grapher/grapher.cpp</a>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="3082d2"></a>QList::QList()</h3>
<p>Constructs an empty list.
<h3 class="fn"><a name="6bedfd"></a>QList::QList(constQList<type>&list)</h3>
<p>Constructs a copy of <em>list.</em>
<p>Each item in <em>list</em> is <a href="#c5746a">appended</a> to this list.
Only the pointers are copied (shallow copy).
<h3 class="fn"><a name="9f06e0"></a>QList::~QList()</h3>
<p>Removes all items from the list and destroys the list.
<p>All list iterators that access this list will be reset.
<p>See also <a href="qcollection.html#a8ef9f">setAutoDelete</a>().
<h3 class="fn">void<a name="c5746a"></a>QList::append(consttype*item)</h3>
<p>Inserts the <em>item</em> at the end of the list.
<p>The inserted item becomes the current list item.
This is equivalent to <code><a href="#876f9c">insert</a>(<a href="#359d9f">count</a>(),item).</code>
<p>The <em>item</em> must not be a null pointer.
<p>See also <a href="#876f9c">insert</a>(), <a href="#3501e8">current</a>() and <a href="#ec8a11">prepend</a>().
<p>Examples:
<a href="grapher-grapher-cpp.html#append">grapher/grapher.cpp</a>
<h3 class="fn">int<a name="0e7e42"></a>QList::at()const</h3>
<p>Returns the index of the current list item. The returned value is -1
if the current item is null.
<p>See also <a href="#3501e8">current</a>().
<h3 class="fn">type*<a name="1cdd9a"></a>QList::at(uintindex)</h3>
<p>Returns a pointer to the item at position <em>index</em> in the list, or
null if the index is out of range.
<p>Sets the current list item to this item if <em>index</em> is valid.
The valid range is <code>0 .. (<a href="#359d9f">count</a>() - 1)</code> inclusive.
<p>This function is very efficient. It starts scanning from the first
item, last item or current item, whichever is closest to <em>index.</em>
<p>See also <a href="#3501e8">current</a>().
<h3 class="fn">void<a name="251773"></a>QList::clear() <code>[virtual]</code></h3>
<p>Removes all items from the list.
<p>The removed items are deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>All list iterators that access this list will be reset.
<p>See also <a href="#00d619">remove</a>(), <a href="#0639ad">take</a>() and <a href="qcollection.html#a8ef9f">setAutoDelete</a>().
<p>Reimplemented from <a href="qcollection.html#e9c603">QCollection.</a>
<h3 class="fn">uint<a name="b49a60"></a>QList::contains(consttype*item)const</h3>
<p>Counts and returns the number of occurrences of <em>item</em> in the list.
<p>The <a href="qglist.html#f2a675">compareItems</a>() function is called when looking for the <em>item</em>
in the list. If compareItems() is not reimplemented, it is more
efficient to call <a href="#e73287">containsRef</a>().
<p>Does not affect the current list item.
<p>See also <a href="#e73287">containsRef</a>() and <a href="qglist.html#f2a675">compareItems</a>().
<h3 class="fn">uint<a name="e73287"></a>QList::containsRef(consttype*item)const</h3>
<p>Counts and returns the number of occurrences of <em>item</em> in the list.
<p>Calling this function is must faster than <a href="#b49a60">contains</a>(), because contains()
compares <em>item</em> with each list item using <a href="qglist.html#f2a675">compareItems</a>().
This function only compares the pointers.
<p>Does not affect the current list item.
<p>See also <a href="#b49a60">contains</a>().
<h3 class="fn">uint<a name="359d9f"></a>QList::count()const <code>[virtual]</code></h3>
<p>Returns the number of items in the list.
<p>See also <a href="#10b215">isEmpty</a>().
<p>Reimplemented from <a href="qcollection.html#2213fa">QCollection.</a>
<h3 class="fn">type*<a name="3501e8"></a>QList::current()const</h3>
<p>Returns a pointer to the current list item. The current item may be
null (implies that the current index is -1).
<p>See also <a href="#0e7e42">at</a>().
<h3 class="fn"><a href="qlnode.html">QLNode</a>*<a name="ed045c"></a>QList::currentNode()const</h3>
<p>Returns a pointer to the current list node.
<p>The node can be kept and removed later using <a href="#85ecce">removeNode</a>().
The advantage is that the item can be removed directly without
searching the list.<p><b>Warning:</b> Do not call this function unless you are an expert.
<p>See also <a href="#85ecce">removeNode</a>(), <a href="#eb9203">takeNode</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">int<a name="3e1af2"></a>QList::find(consttype*item)</h3>
<p>Finds the first occurrence of <em>item</em> in the list.
<p>If the item is found, the list sets the current item to point to
the found item and returns the index of this item.
If the item is not found, the list sets the current item to null,
the current index to -1 and returns -1.
<p>The <a href="qglist.html#f2a675">compareItems</a>() function is called when searching for the item
in the list. If compareItems() is not reimplemented, it is more
efficient to call <a href="#f15291">findRef</a>().
<p>See also <a href="#493c49">findNext</a>(), <a href="#f15291">findRef</a>(), <a href="qglist.html#f2a675">compareItems</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">int<a name="493c49"></a>QList::findNext(consttype*item)</h3>
<p>Finds the next occurrence of <em>item</em> in the list, starting from
the current list item.
<p>If the item is found, the list sets the current item to point to
the found item and returns the index of this item.
If the item is not found, the list sets the current item to null,
the current index to -1 and returns -1.
<p>The <a href="qglist.html#f2a675">compareItems</a>() function is called when searching for the item
in the list. If compareItems() is not reimplemented, it is more
efficient to call <a href="#9da100">findNextRef</a>().
<p>See also <a href="#3e1af2">find</a>(), <a href="#9da100">findNextRef</a>(), <a href="qglist.html#f2a675">compareItems</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">int<a name="9da100"></a>QList::findNextRef(consttype*item)</h3>
<p>Finds the next occurrence of <em>item</em> in the list, starting from the
current list item.
<p>If the item is found, the list sets the current item to point to
the found item and returns the index of this item.
If the item is not found, the list sets the current item to null,
the current index to -1 and returns -1.
<p>Calling this function is must faster than <a href="#493c49">findNext</a>(), because findNext()
compares <em>item</em> with each list item using <a href="qglist.html#f2a675">compareItems</a>().
This function only compares the pointers.
<p>See also <a href="#f15291">findRef</a>(), <a href="#493c49">findNext</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">int<a name="f15291"></a>QList::findRef(consttype*item)</h3>
<p>Finds the first occurrence of <em>item</em> in the list.
<p>If the item is found, the list sets the current item to point to
the found item and returns the index of this item.
If the item is not found, the list sets the current item to null,
the current index to -1 and returns -1.
<p>Calling this function is must faster than <a href="#3e1af2">find</a>(), because find()
compares <em>item</em> with each list item using <a href="qglist.html#f2a675">compareItems</a>().
This function only compares the pointers.
<p>See also <a href="#9da100">findNextRef</a>(), <a href="#3e1af2">find</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">type*<a name="e625f9"></a>QList::first()</h3>
<p>Returns a pointer to the first item in the list and makes this the
current list item, or null if the list is empty.
<p>See also <a href="#e33b29">getFirst</a>(), <a href="#cb27aa">last</a>(), <a href="#f95ddd">next</a>(), <a href="#ace811">prev</a>() and <a href="#3501e8">current</a>().
<p>Examples:
<a href="grapher-grapher-cpp.html#first">grapher/grapher.cpp</a>
<h3 class="fn">type*<a name="e33b29"></a>QList::getFirst()const</h3>
<p>Returns a pointer to the first item in the list, or null if the
list is empty.
<p>Does not affect the current list item.
<p>See also <a href="#e625f9">first</a>() and <a href="#4fbf59">getLast</a>().
<h3 class="fn">type*<a name="4fbf59"></a>QList::getLast()const</h3>
<p>Returns a pointer to the last item in the list, or null if the
list is empty.
<p>Does not affect the current list item.
<p>See also <a href="#cb27aa">last</a>() and <a href="#e33b29">getFirst</a>().
<h3 class="fn">void<a name="bf9354"></a>QList::inSort(consttype*item)</h3>
<p>Inserts the <em>item</em> at its sorted position in the list.
<p>The sort order depends on the virtual <a href="qglist.html#f2a675">QGList::compareItems</a>() function.
All items must be inserted with inSort() to maintain the sorting order.
<p>The inserted item becomes the current list item.
<p>The <em>item</em> must not be a null pointer.
<p>Please note that inSort is slow. If you want to insert lots of items
in a list and sort after inserting then you should use <a href="#1ef901">sort</a>().
inSort() takes up to O(<a href="n.html">n</a>) compares. That means inserting n items in
your list will need O(n^2) compares while sort() only needs O(n*logn)
for the same task. So you inSort() only if you already have a pre-sorted
list and want to insert only few additional items.
<p>See also <a href="#876f9c">insert</a>(), <a href="qglist.html#f2a675">QGList::compareItems</a>(), <a href="#3501e8">current</a>() and <a href="#1ef901">sort</a>().
<h3 class="fn">bool<a name="876f9c"></a>QList::insert(uintindex, consttype*item)</h3>
<p>Inserts the <em>item</em> at the position <em>index</em> in the list.
<p>Returns TRUE if successful, or FALSE if <em>index</em> is out of range.
The valid range is <code>0 .. <a href="#359d9f">count</a>()</code> inclusive.
The item is appended if <em>index</em> == count().
<p>The inserted item becomes the current list item.
<p>The <em>item</em> must not be a null pointer.
<p>See also <a href="#c5746a">append</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">bool<a name="10b215"></a>QList::isEmpty()const</h3>
<p>Returns TRUE if the list is empty, i.e. <a href="#359d9f">count</a>() == 0. Returns FALSE
otherwise.
<p>See also <a href="#359d9f">count</a>().
<h3 class="fn">type*<a name="cb27aa"></a>QList::last()</h3>
<p>Returns a pointer to the last item in the list and makes this the
current list item, or null if the list is empty.
<p>See also <a href="#4fbf59">getLast</a>(), <a href="#e625f9">first</a>(), <a href="#f95ddd">next</a>(), <a href="#ace811">prev</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">type*<a name="f95ddd"></a>QList::next()</h3>
<p>Returns a pointer to the item succeeding the current item.
Returns null if the current item is null or equal to the last item.
<p>Makes the succeeding item current. If the current item before this
function call was the last item, the current item will be set to null.
If the current item was null, this function does nothing.
<p>See also <a href="#e625f9">first</a>(), <a href="#cb27aa">last</a>(), <a href="#ace811">prev</a>() and <a href="#3501e8">current</a>().
<p>Examples:
<a href="grapher-grapher-cpp.html#next">grapher/grapher.cpp</a>
<h3 class="fn">QList<type>&<a name="95ba1b"></a>QList::operator=(constQList<type>&list)</h3>
<p>Assigns <em>list</em> to this list and returns a reference to this list.
<p>This list is first cleared, then each item in <em>list</em> is
<a href="#c5746a">appended</a> to this list. Only the pointers are copied
(shallow copy), unless <a href="qcollection.html#55065e">newItem</a>() has been reimplemented().
<h3 class="fn">bool<a name="5b7aa9"></a>QList::operator==(constQList<type>&list)const</h3>
<p>Compares this list with <em>list.</em> Retruns TRUE if the lists
contain the same data, else FALSE.
<h3 class="fn">void<a name="ec8a11"></a>QList::prepend(consttype*item)</h3>
<p>Inserts the <em>item</em> at the start of the list.
<p>The inserted item becomes the current list item.
This is equivalent to <code><a href="#876f9c">insert</a>(0,item).</code>
<p>The <em>item</em> must not be a null pointer.
<p>See also <a href="#c5746a">append</a>(), <a href="#876f9c">insert</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">type*<a name="ace811"></a>QList::prev()</h3>
<p>Returns a pointer to the item preceding the current item.
Returns null if the current item is null or equal to the first item.
<p>Makes the preceding item current. If the current item before this
function call was the first item, the current item will be set to null.
If the current item was null, this function does nothing.
<p>See also <a href="#e625f9">first</a>(), <a href="#cb27aa">last</a>(), <a href="#f95ddd">next</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">bool<a name="00d619"></a>QList::remove()</h3>
<p>Removes the current list item.
<p>Returns TRUE if successful, or FALSE if the current item is null.
<p>The removed item is deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>The item after the removed item becomes the new current list item if
the removed item is not the last item in the list. If the last item
is removed, the new last item becomes the current item. The current
item is set to null if the list becomes empty.
<p>All list iterators that refer to the removed item will be set to point
to the new current item.
<p>See also <a href="#0639ad">take</a>(), <a href="#251773">clear</a>(), <a href="qcollection.html#a8ef9f">setAutoDelete</a>(), <a href="#3501e8">current</a>() and <a href="#f3ac41">removeRef</a>().
<h3 class="fn">bool<a name="165d79"></a>QList::remove(consttype*item)</h3>
<p>Removes the first occurrence of <em>item</em> from the list.
<p>Returns TRUE if successful, or FALSE if the item could not be found in the
list.
<p>The removed item is deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>The <a href="qglist.html#f2a675">compareItems</a>() function is called when searching for the item
in the list. If compareItems() is not reimplemented, it is more
efficient to call <a href="#f3ac41">removeRef</a>().
<p>The item after the removed item becomes the new current list item if
the removed item is not the last item in the list. If the last item
is removed, the new last item becomes the current item. The current
item is set to null if the list becomes empty.
<p>All list iterators that refer to the removed item will be set to point
to the new current item.
<p>See also <a href="#f3ac41">removeRef</a>(), <a href="#0639ad">take</a>(), <a href="#251773">clear</a>(), <a href="qcollection.html#a8ef9f">setAutoDelete</a>(), <a href="qglist.html#f2a675">compareItems</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">bool<a name="c3eaf3"></a>QList::remove(uintindex)</h3>
<p>Removes the item at position <em>index</em> in the list.
<p>Returns TRUE if successful, or FALSE if <em>index</em> is out of range.
The valid range is <code>0 .. (<a href="#359d9f">count</a>() - 1)</code> inclusive.
<p>The removed item is deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>The item after the removed item becomes the new current list item if
the removed item is not the last item in the list. If the last item
is removed, the new last item becomes the current item. The current
item is
set to null if the list becomes empty.
<p>All list iterators that refer to the removed item will be set to point
to the new current item.
<p>See also <a href="#0639ad">take</a>(), <a href="#251773">clear</a>(), <a href="qcollection.html#a8ef9f">setAutoDelete</a>(), <a href="#3501e8">current</a>() and <a href="#f3ac41">removeRef</a>().
<h3 class="fn">bool<a name="7d8a6f"></a>QList::removeFirst()</h3>
<p>Removes the first item from the list.
Returns TRUE if successful, or FALSE if the list is empty.
<p>The removed item is deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>The first item in the list becomes the new current list item.
The current item is set to null if the list becomes empty.
<p>All list iterators that refer to the removed item will be set to point
to the new current item.
<p>See also <a href="#a64806">removeLast</a>(), <a href="qcollection.html#a8ef9f">setAutoDelete</a>(), <a href="#3501e8">current</a>() and <a href="#00d619">remove</a>().
<h3 class="fn">bool<a name="a64806"></a>QList::removeLast()</h3>
<p>Removes the last item from the list.
Returns TRUE if successful, or FALSE if the list is empty.
<p>The removed item is deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>The last item in the list becomes the new current list item.
The current item is set to null if the list becomes empty.
<p>All list iterators that refer to the removed item will be set to point
to the new current item.
<p>See also <a href="#7d8a6f">removeFirst</a>(), <a href="qcollection.html#a8ef9f">setAutoDelete</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">void<a name="85ecce"></a>QList::removeNode(<a href="qlnode.html">QLNode</a>*node)</h3>
<p>Removes the <em>node</em> from the list.
<p>This node must exist in the list, otherwise the program may crash.
<p>The removed item is deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>The first item in the list will become the new current list item.
The current item is set to null if the list becomes empty.
<p>All list iterators that refer to the removed item will be set to point to
the item succeeding this item, or the preceding item if the removed item
was the last item.<p><b>Warning:</b> Do not call this function unless you are an expert.
<p>See also <a href="#eb9203">takeNode</a>(), <a href="#ed045c">currentNode</a>(), <a href="#00d619">remove</a>() and <a href="#f3ac41">removeRef</a>().
<h3 class="fn">bool<a name="f3ac41"></a>QList::removeRef(consttype*item)</h3>
<p>Removes the first occurrence of <em>item</em> from the list.
<p>Returns TRUE if successful, or FALSE if the item cannot be found in the
list.
<p>The removed item is deleted if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled.
<p>The list is scanned until the pointer <em>item</em> is found. It is removed
if it is found.
<p>Equivalent to:
<pre> if ( list.findRef(item) != -1 )
list.remove();
</pre>
<p>The item after the removed item becomes the new current list item if
the removed item is not the last item in the list. If the last item
is removed, the new last item becomes the current item. The current
item is set to null if the list becomes empty.
<p>All list iterators that refer to the removed item will be set to point
to the new current item.
<p>See also <a href="#00d619">remove</a>(), <a href="#251773">clear</a>(), <a href="qcollection.html#a8ef9f">setAutoDelete</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">void<a name="1ef901"></a>QList::sort()</h3>
<p>Sorts the list by the result of the virtual <a href="qglist.html#f2a675">compareItems</a>() function.
<p>The Heap-Sort algorithm is used for sorting. It sorts <a href="n.html">n</a> items with
O(n*log n) compares. This is the asymptotic optimal solution of the
sorting problem.
<p>If the items in your list support operator< and operator== then you
might be better off with <a href="qsortedlist.html">QSortedList</a> since it implements the
compareItems() function for you using these two operators.
<p>See also <a href="#bf9354">inSort</a>().
<h3 class="fn">type*<a name="0639ad"></a>QList::take()</h3>
<p>Takes the current item out of the list without deleting it (even if
<a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled).
Returns a pointer to the item taken out of the list, or null if
the current item is null.
<p>The item after the taken item becomes the new current list item if
the taken item is not the last item in the list. If the last item
is taken, the new last item becomes the current item. The current
item is set to null if the list becomes empty.
<p>All list iterators that refer to the taken item will be set to point to
the new current item.
<p>See also <a href="#00d619">remove</a>(), <a href="#251773">clear</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">type*<a name="e1f650"></a>QList::take(uintindex)</h3>
<p>Takes the item at position <em>index</em> out of the list without
deleting it (even if <a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled).
<p>Returns a pointer to the item taken out of the list, or null if
the index is out of range.
The valid range is <code>0 .. (<a href="#359d9f">count</a>() - 1)</code> inclusive.
<p>The item after the taken item becomes the new current list item if
the taken item is not the last item in the list. If the last item
is taken, the new last item becomes the current item. The current
item is set to null if the list becomes empty.
<p>All list iterators that refer to the taken item will be set to point to
the new current item.
<p>See also <a href="#00d619">remove</a>(), <a href="#251773">clear</a>() and <a href="#3501e8">current</a>().
<h3 class="fn">type*<a name="eb9203"></a>QList::takeNode(<a href="qlnode.html">QLNode</a>*node)</h3>
<p>Takes the <em>node</em> out of the list without deleting its item (even if
<a href="qcollection.html#a8ef9f">auto-deletion</a> is enabled).
Returns a pointer to the item taken out of the list.
<p>This node must exist in the list, otherwise the program may crash.
<p>The first item in the list becomes the new current list item.
<p>All list iterators that refer to the taken item will be set to point to
the item succeeding this item, or the preceding item if the taken item
was the last item.<p><b>Warning:</b> Do not call this function unless you are an expert.
<p>See also <a href="#85ecce">removeNode</a>() and <a href="#ed045c">currentNode</a>().
<h3 class="fn">void<a name="df4c31"></a>QList::toVector(<a href="qgvector.html">QGVector</a>*vec)const</h3>
<p>Stores all list items in the vector <em>vec.</em>
<p>The vector must be have the same item type, otherwise the result
will be undefined.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|