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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qvaluelist.doc:41 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQValueList Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQValueList Class Reference</h1>
<p>The TQValueList class is a value-based template class that
provides lists.
<a href="#details">More...</a>
<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when TQt is built with thread support.</p>
<p><tt>#include <<a href="qvaluelist-h.html">ntqvaluelist.h</a>></tt>
<p>Inherited by <a href="qcanvasitemlist.html">TQCanvasItemList</a>, <a href="ntqstringlist.html">TQStringList</a>, and <a href="ntqvaluestack.html">TQValueStack</a>.
<p><a href="qvaluelist-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn>typedef TQValueListIterator<T> <a href="#iterator"><b>iterator</b></a></li>
<li class=fn>typedef TQValueListConstIterator<T> <a href="#const_iterator"><b>const_iterator</b></a></li>
<li class=fn>typedef T <a href="#value_type"><b>value_type</b></a></li>
<li class=fn>typedef value_type * <a href="#pointer"><b>pointer</b></a></li>
<li class=fn>typedef const value_type * <a href="#const_pointer"><b>const_pointer</b></a></li>
<li class=fn>typedef value_type & <a href="#reference"><b>reference</b></a></li>
<li class=fn>typedef const value_type & <a href="#const_reference"><b>const_reference</b></a></li>
<li class=fn>typedef size_t <a href="#size_type"><b>size_type</b></a></li>
<li class=fn><a href="#TQValueList"><b>TQValueList</b></a> ()</li>
<li class=fn><a href="#TQValueList-2"><b>TQValueList</b></a> ( const TQValueList<T> & l )</li>
<li class=fn><a href="#TQValueList-3"><b>TQValueList</b></a> ( const std::list<T> & l )</li>
<li class=fn><a href="#~TQValueList"><b>~TQValueList</b></a> ()</li>
<li class=fn>TQValueList<T> & <a href="#operator-eq"><b>operator=</b></a> ( const TQValueList<T> & l )</li>
<li class=fn>TQValueList<T> & <a href="#operator-eq-2"><b>operator=</b></a> ( const std::list<T> & l )</li>
<li class=fn>bool <a href="#operator-eq-eq-2"><b>operator==</b></a> ( const std::list<T> & l ) const</li>
<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const TQValueList<T> & l ) const</li>
<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const TQValueList<T> & l ) const</li>
<li class=fn>iterator <a href="#begin-2"><b>begin</b></a> ()</li>
<li class=fn>const_iterator <a href="#begin"><b>begin</b></a> () const</li>
<li class=fn>const_iterator <a href="#constBegin"><b>constBegin</b></a> () const</li>
<li class=fn>iterator <a href="#end"><b>end</b></a> ()</li>
<li class=fn>const_iterator <a href="#end-2"><b>end</b></a> () const</li>
<li class=fn>const_iterator <a href="#constEnd"><b>constEnd</b></a> () const</li>
<li class=fn>iterator <a href="#insert"><b>insert</b></a> ( iterator it, const T & x )</li>
<li class=fn>uint <a href="#remove-2"><b>remove</b></a> ( const T & x )</li>
<li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
<li class=fn>TQValueList<T> & <a href="#operator-lt-lt"><b>operator<<</b></a> ( const T & x )</li>
<li class=fn>size_type <a href="#size"><b>size</b></a> () const</li>
<li class=fn>bool <a href="#empty"><b>empty</b></a> () const</li>
<li class=fn>void <a href="#push_front"><b>push_front</b></a> ( const T & x )</li>
<li class=fn>void <a href="#push_back"><b>push_back</b></a> ( const T & x )</li>
<li class=fn>iterator <a href="#erase"><b>erase</b></a> ( iterator it )</li>
<li class=fn>iterator <a href="#erase-2"><b>erase</b></a> ( iterator first, iterator last )</li>
<li class=fn>reference <a href="#front"><b>front</b></a> ()</li>
<li class=fn>const_reference <a href="#front-2"><b>front</b></a> () const</li>
<li class=fn>reference <a href="#back"><b>back</b></a> ()</li>
<li class=fn>const_reference <a href="#back-2"><b>back</b></a> () const</li>
<li class=fn>void <a href="#pop_front"><b>pop_front</b></a> ()</li>
<li class=fn>void <a href="#pop_back"><b>pop_back</b></a> ()</li>
<li class=fn>void <a href="#insert-2"><b>insert</b></a> ( iterator pos, size_type n, const T & x )</li>
<li class=fn>TQValueList<T> <a href="#operator+"><b>operator+</b></a> ( const TQValueList<T> & l ) const</li>
<li class=fn>TQValueList<T> & <a href="#operator+-eq"><b>operator+=</b></a> ( const TQValueList<T> & l )</li>
<li class=fn>iterator <a href="#fromLast-2"><b>fromLast</b></a> ()</li>
<li class=fn>const_iterator <a href="#fromLast"><b>fromLast</b></a> () const</li>
<li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
<li class=fn>iterator <a href="#append"><b>append</b></a> ( const T & x )</li>
<li class=fn>iterator <a href="#prepend"><b>prepend</b></a> ( const T & x )</li>
<li class=fn>iterator <a href="#remove"><b>remove</b></a> ( iterator it )</li>
<li class=fn>T & <a href="#first"><b>first</b></a> ()</li>
<li class=fn>const T & <a href="#first-2"><b>first</b></a> () const</li>
<li class=fn>T & <a href="#last"><b>last</b></a> ()</li>
<li class=fn>const T & <a href="#last-2"><b>last</b></a> () const</li>
<li class=fn>T & <a href="#operator[]-2"><b>operator[]</b></a> ( size_type i )</li>
<li class=fn>const T & <a href="#operator[]"><b>operator[]</b></a> ( size_type i ) const</li>
<li class=fn>iterator <a href="#at-2"><b>at</b></a> ( size_type i )</li>
<li class=fn>const_iterator <a href="#at"><b>at</b></a> ( size_type i ) const</li>
<li class=fn>iterator <a href="#find"><b>find</b></a> ( const T & x )</li>
<li class=fn>const_iterator <a href="#find-2"><b>find</b></a> ( const T & x ) const</li>
<li class=fn>iterator <a href="#find-3"><b>find</b></a> ( iterator it, const T & x )</li>
<li class=fn>const_iterator <a href="#find-4"><b>find</b></a> ( const_iterator it, const T & x ) const</li>
<li class=fn>int <a href="#findIndex"><b>findIndex</b></a> ( const T & x ) const</li>
<li class=fn>size_type <a href="#contains"><b>contains</b></a> ( const T & x ) const</li>
<li class=fn>size_type <a href="#count"><b>count</b></a> () const</li>
<li class=fn>TQValueList<T> & <a href="#operator+-eq-2"><b>operator+=</b></a> ( const T & x )</li>
<li class=fn>typedef TQValueListIterator<T> <a href="#Iterator"><b>Iterator</b></a></li>
<li class=fn>typedef TQValueListConstIterator<T> <a href="#ConstIterator"><b>ConstIterator</b></a></li>
</ul>
<h2>Related Functions</h2>
<ul>
<li class=fn>TQDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( TQDataStream & s, TQValueList<T> & l )</li>
<li class=fn>TQDataStream & <a href="#operator-lt-lt-2"><b>operator<<</b></a> ( TQDataStream & s, const TQValueList<T> & l )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQValueList class is a value-based template class that
provides lists.
<p>
<p> TQValueList is a TQt implementation of an STL-like list container.
It can be used in your application if the standard <tt>list</tt> is not
available for your target platform(s). TQValueList is part of the
<a href="ntqtl.html">TQt Template Library</a>.
<p> TQValueList<T> defines a template instance to create a list of
values that all have the class T. Note that TQValueList does not
store pointers to the members of the list; it holds a copy of
every member. This is why these kinds of classes are called "value
based"; <a href="ntqptrlist.html">TQPtrList</a> and <a href="ntqdict.html">TQDict</a> are "pointer based".
<p> TQValueList contains and manages a collection of objects of type T
and provides iterators that allow the contained objects to be
addressed. TQValueList owns the contained items. For more relaxed
ownership semantics, see <a href="ntqptrcollection.html">TQPtrCollection</a> and friends which are
pointer-based containers.
<p> Some classes cannot be used within a TQValueList, for example, all
classes derived from <a href="ntqobject.html">TQObject</a> and thus all classes that implement
widgets. Only values can be used in a TQValueList. To qualify as a
value the class must provide:
<ul>
<li> a copy constructor;
<li> an assignment operator;
<li> a default constructor, i.e. a constructor that does not take any arguments.
</ul>
<p> Note that C++ defaults to field-by-field assignment operators and
copy constructors if no explicit version is supplied. In many
cases this is sufficient.
<p> In addition, some compilers (e.g. Sun CC) might require that the
class provides an equality operator (<a href="#operator-eq-eq">operator==</a>()).
<p> TQValueList's function naming is consistent with the other TQt
classes (e.g. <a href="#count">count</a>(), <a href="#isEmpty">isEmpty</a>()). TQValueList also provides extra
functions for compatibility with STL algorithms, such as <a href="#size">size</a>()
and <a href="#empty">empty</a>(). Programmers already familiar with the STL <tt>list</tt> may
prefer to use the STL-compatible functions.
<p> Example:
<pre>
class Employee
{
public:
Employee(): sn(0) {}
Employee( const <a href="ntqstring.html">TQString</a>& forename, const <a href="ntqstring.html">TQString</a>& surname, int salary )
: fn(forename), sn(surname), sal(salary)
{}
<a href="ntqstring.html">TQString</a> forename() const { return fn; }
<a href="ntqstring.html">TQString</a> surname() const { return sn; }
int salary() const { return sal; }
void setSalary( int salary ) { sal = salary; }
private:
<a href="ntqstring.html">TQString</a> fn;
<a href="ntqstring.html">TQString</a> sn;
int sal;
};
typedef TQValueList<Employee> EmployeeList;
EmployeeList list;
list.append( Employee("John", "Doe", 50000) );
list.append( Employee("Jane", "Williams", 80000) );
list.append( Employee("Tom", "Jones", 60000) );
Employee mary( "Mary", "Hawthorne", 90000 );
list.append( mary );
mary.setSalary( 100000 );
EmployeeList::<a href="#iterator">iterator</a> it;
for ( it = list.begin(); it != list.end(); ++it )
cout << (*it).surname().latin1() << ", " <<
(*it).forename().latin1() << " earns " <<
(*it).salary() << endl;
// Output:
// Doe, John earns 50000
// Williams, Jane earns 80000
// Hawthorne, Mary earns 90000
// Jones, Tom earns 60000
</pre>
<p> Notice that the latest changes to Mary's salary did not affect the
value in the list because the list created a copy of Mary's entry.
<p> There are several ways to find items in the list. The <a href="#begin">begin</a>() and
<a href="#end">end</a>() functions return iterators to the beginning and end of the
list. The advantage of getting an iterator is that you can move
forward or backward from this position by
incrementing/decrementing the iterator. The iterator returned by
end() points to the item which is one <em>past</em> the last item in the
container. The past-the-end iterator is still associated with the
list it belongs to, however it is <em>not</em> dereferenceable;
<a href="ntqsize.html#operator*-4">operator*</a>() will not return a well-defined value. If the list is
<a href="#empty">empty</a>(), the iterator returned by begin() will equal the iterator
returned by end().
<p> Another way to find an item in the list is by using the <a href="ntqtl.html#qFind">qFind()</a> algorithm. For example:
<p> <pre>
TQValueList<int> list;
...
TQValueList<int>::<a href="#iterator">iterator</a> it = qFind( list.<a href="#begin">begin</a>(), list.<a href="#end">end</a>(), 3 );
if ( it != list.<a href="#end">end</a>() )
// it points to the found item
</pre>
<p> It is safe to have multiple iterators a the list at the same
time. If some member of the list is removed, only iterators
pointing to the removed member become invalid. Inserting into the
list does not invalidate any iterator. For convenience, the
function <a href="#last">last</a>() returns a reference to the last item in the list,
and <a href="#first">first</a>() returns a reference to the the first item. If the
list is empty(), both last() and first() have undefined behavior
(your application will crash or do unpredictable things). Use
last() and first() with caution, for example:
<p> <pre>
TQValueList<int> list;
list.<a href="#append">append</a>( 1 );
list.<a href="#append">append</a>( 2 );
list.<a href="#append">append</a>( 3 );
...
if ( !list.<a href="#empty">empty</a>() ) {
// OK, modify the first item
int& i = list.<a href="#first">first</a>();
i = 18;
}
...
TQValueList<double> dlist;
double d = dlist.<a href="#last">last</a>(); // undefined
</pre>
<p> Because TQValueList is value-based there is no need to be careful
about deleting items in the list. The list holds its own copies
and will free them if the corresponding member or the list itself
is deleted. You can force the list to free all of its items with
<a href="#clear">clear</a>().
<p> TQValueList is <a href="shclass.html#shared-implicitly">shared implicitly</a>, which means it can be copied in
constant time, i.e. O(1). If multiple TQValueList instances share
the same data and one needs to modify its contents, this modifying
instance makes a copy and modifies its private copy; therefore it
does not affect the other instances; this takes O(n) time. This is
often called "copy on write". If a TQValueList is being used in a
multi-threaded program, you must protect all access to the list.
See <a href="ntqmutex.html">TQMutex</a>.
<p> There are several ways to insert items into the list. The
<a href="#prepend">prepend</a>() and <a href="#append">append</a>() functions insert items at the beginning and
the end of the list respectively. The <a href="#insert">insert</a>() function comes in
several flavors and can be used to add one or more items at
specific positions within the list.
<p> Items can also be removed from the list in several ways. There
are several variants of the <a href="#remove">remove</a>() function, which removes a
specific item from the list. The remove() function will find and
remove items according to a specific item value.
<p> Lists can also be sorted using the <a href="ntqtl.html">TQt Template
Library</a>. For example with qHeapSort():
<p> Example:
<pre>
TQValueList<int> list;
list.<a href="#append">append</a>( 5 );
list.<a href="#append">append</a>( 8 );
list.<a href="#append">append</a>( 3 );
list.<a href="#append">append</a>( 4 );
qHeapSort( list );
</pre>
<p> <p>See also <a href="qvaluelistiterator.html">TQValueListIterator</a>, <a href="ntqtl.html">TQt Template Library Classes</a>, <a href="shared.html">Implicitly and Explicitly Shared Classes</a>, and <a href="tools.html">Non-GUI Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="ConstIterator"></a>TQValueList::ConstIterator</h3>
<p> This iterator is an instantiation of <a href="qvaluelistconstiterator.html">TQValueListConstIterator</a> for
the same type as this TQValueList. In other words, if you
instantiate TQValueList<int>, ConstIterator is a
TQValueListConstIterator<int>. Several member function use it, such
as <a href="#begin">TQValueList::begin</a>(), which returns an iterator pointing to the
first item in the list.
<p> Functionally, this is almost the same as Iterator. The only
difference is you cannot use ConstIterator for non-const
operations, and that the compiler can often generate better code
if you use ConstIterator.
<p> <p>See also <a href="qvaluelistiterator.html">TQValueListIterator</a> and <a href="#Iterator">Iterator</a>.
<h3 class=fn><a name="Iterator"></a>TQValueList::Iterator</h3>
<p> This iterator is an instantiation of <a href="qvaluelistiterator.html">TQValueListIterator</a> for the
same type as this TQValueList. In other words, if you instantiate
TQValueList<int>, Iterator is a TQValueListIterator<int>. Several
member function use it, such as <a href="#begin">TQValueList::begin</a>(), which returns
an iterator pointing to the first item in the list.
<p> Functionally, this is almost the same as ConstIterator. The only
difference is that you cannot use ConstIterator for non-const
operations, and that the compiler can often generate better code
if you use ConstIterator.
<p> <p>See also <a href="qvaluelistiterator.html">TQValueListIterator</a> and <a href="#ConstIterator">ConstIterator</a>.
<h3 class=fn><a name="const_iterator"></a>TQValueList::const_iterator</h3>
The list's const iterator type, <a href="qvaluelistconstiterator.html">TQValueListConstIterator</a>.
<h3 class=fn><a name="const_pointer"></a>TQValueList::const_pointer</h3>
The const pointer to T type.
<h3 class=fn><a name="const_reference"></a>TQValueList::const_reference</h3>
The const reference to T type.
<h3 class=fn><a name="iterator"></a>TQValueList::iterator</h3>
The list's iterator type, <a href="qvaluelistiterator.html">TQValueListIterator</a>.
<h3 class=fn><a name="pointer"></a>TQValueList::pointer</h3>
The pointer to T type.
<h3 class=fn><a name="reference"></a>TQValueList::reference</h3>
The reference to T type.
<h3 class=fn><a name="size_type"></a>TQValueList::size_type</h3>
An unsigned integral type, used to represent various sizes.
<h3 class=fn><a name="value_type"></a>TQValueList::value_type</h3>
The type of the object stored in the list, T.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQValueList"></a>TQValueList::TQValueList ()
</h3>
<p> Constructs an empty list.
<h3 class=fn><a name="TQValueList-2"></a>TQValueList::TQValueList ( const <a href="ntqvaluelist.html">TQValueList</a><T> & l )
</h3>
<p> Constructs a copy of <em>l</em>.
<p> This operation takes O(1) time because TQValueList is <a href="shclass.html#implicitly-shared">implicitly shared</a>.
<p> The first modification to a list will take O(n) time.
<h3 class=fn><a name="TQValueList-3"></a>TQValueList::TQValueList ( const std::list<T> & l )
</h3>
<p> Contructs a copy of <em>l</em>.
<p> This constructor is provided for compatibility with STL
containers.
<h3 class=fn><a name="~TQValueList"></a>TQValueList::~TQValueList ()
</h3>
<p> Destroys the list. References to the values in the list and all
iterators of this list become invalidated. Note that it is
impossible for an iterator to check whether or not it is valid:
TQValueList is highly tuned for performance, not for error
checking.
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="append"></a>TQValueList::append ( const T & x )
</h3>
<p> Inserts <em>x</em> at the end of the list.
<p> <p>See also <a href="#insert">insert</a>() and <a href="#prepend">prepend</a>().
<p>Examples: <a href="checklists-example.html#x434">checklists/checklists.cpp</a> and <a href="simple-font-demo-example.html#x2853">fonts/simple-qfont-demo/viewer.cpp</a>.
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="at"></a>TQValueList::at ( <a href="ntqvaluelist.html#size_type">size_type</a> i ) const
</h3>
<p> Returns an iterator pointing to the item at position <em>i</em> in the
list, or an undefined value if the index is out of range.
<p> <b>Warning:</b> This function uses a linear search and can be extremely
slow for large lists. TQValueList is not optimized for random item
access. If you need random access use a different container, such
as <a href="ntqvaluevector.html">TQValueVector</a>.
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="at-2"></a>TQValueList::at ( <a href="ntqvaluelist.html#size_type">size_type</a> i )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns an iterator pointing to the item at position <em>i</em> in the
list, or an undefined value if the index is out of range.
<p>
<h3 class=fn><a href="ntqvaluelist.html#reference">reference</a> <a name="back"></a>TQValueList::back ()
</h3>
<p> Returns a reference to the last item. If the list contains no last
item (i.e. <a href="#empty">empty</a>() returns TRUE), the return value is undefined.
<p> This function is provided for STL compatibility. It is equivalent
to <a href="#last">last</a>().
<p> <p>See also <a href="#front">front</a>().
<h3 class=fn><a href="ntqvaluelist.html#const_reference">const_reference</a> <a name="back-2"></a>TQValueList::back () const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="begin"></a>TQValueList::begin () const
</h3>
<p> Returns an iterator pointing to the first item in the list. This
iterator equals <a href="#end">end</a>() if the list is empty.
<p> <p>See also <a href="#first">first</a>(), <a href="#end">end</a>(), and <a href="#constBegin">constBegin</a>().
<p>Examples: <a href="canvas-example.html#x2952">canvas/canvas.cpp</a>, <a href="tutorial2-06.html#x2588">chart/canvasview.cpp</a>, <a href="tutorial2-03.html#x2554">chart/element.cpp</a>, <a href="checklists-example.html#x435">checklists/checklists.cpp</a>, <a href="sql.html#x2197">sql/overview/insert/main.cpp</a>, <a href="statistics-example.html#x2789">table/statistics/statistics.cpp</a>, and <a href="themes-example.html#x344">themes/themes.cpp</a>.
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="begin-2"></a>TQValueList::begin ()
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns an iterator pointing to the first item in the list. This
iterator equals <a href="#end">end</a>() if the list is empty.
<p> <p>See also <a href="#first">first</a>() and <a href="#end">end</a>().
<h3 class=fn>void <a name="clear"></a>TQValueList::clear ()
</h3>
<p> Removes all items from the list.
<p> <p>See also <a href="#remove">remove</a>().
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="constBegin"></a>TQValueList::constBegin () const
</h3>
<p> Returns an iterator pointing to the first item in the list. This
iterator equals <a href="#constEnd">constEnd</a>() if the list is empty.
<p> <p>See also <a href="#begin">begin</a>().
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="constEnd"></a>TQValueList::constEnd () const
</h3>
<p> Returns an iterator pointing <em>past</em> the last item in the list.
This iterator equals <a href="#constBegin">constBegin</a>() if the list is empty.
<p> <p>See also <a href="#end">end</a>().
<h3 class=fn><a href="ntqvaluelist.html#size_type">size_type</a> <a name="contains"></a>TQValueList::contains ( const T & x ) const
</h3>
<p> Returns the number of occurrences of the value <em>x</em> in the list.
<h3 class=fn><a href="ntqvaluelist.html#size_type">size_type</a> <a name="count"></a>TQValueList::count () const
</h3>
<p> Returns the number of items in the list.
<p> <p>See also <a href="#isEmpty">isEmpty</a>().
<p>Examples: <a href="tutorial2-03.html#x2555">chart/element.cpp</a>, <a href="fileiconview-example.html#x874">fileiconview/qfileiconview.cpp</a>, and <a href="statistics-example.html#x2790">table/statistics/statistics.cpp</a>.
<h3 class=fn>bool <a name="empty"></a>TQValueList::empty () const
</h3>
<p> Returns TRUE if the list contains no items; otherwise returns
FALSE.
<p> <p>See also <a href="#size">size</a>().
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="end"></a>TQValueList::end ()
</h3>
<p> Returns an iterator pointing <em>past</em> the last item in the list.
This iterator equals <a href="#begin">begin</a>() if the list is empty.
<p> <p>See also <a href="#last">last</a>(), <a href="#begin">begin</a>(), and <a href="#constEnd">constEnd</a>().
<p>Examples: <a href="canvas-example.html#x2953">canvas/canvas.cpp</a>, <a href="tutorial2-06.html#x2589">chart/canvasview.cpp</a>, <a href="tutorial2-03.html#x2556">chart/element.cpp</a>, <a href="checklists-example.html#x436">checklists/checklists.cpp</a>, <a href="sql.html#x2198">sql/overview/insert/main.cpp</a>, <a href="statistics-example.html#x2791">table/statistics/statistics.cpp</a>, and <a href="themes-example.html#x345">themes/themes.cpp</a>.
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="end-2"></a>TQValueList::end () const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns an iterator pointing <em>past</em> the last item in the list.
This iterator equals <a href="#begin">begin</a>() if the list is empty.
<p> <p>See also <a href="#last">last</a>() and <a href="#begin">begin</a>().
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="erase"></a>TQValueList::erase ( <a href="ntqvaluelist.html#iterator">iterator</a> it )
</h3>
<p> Removes the item pointed to by <em>it</em> from the list. No iterators
other than <em>it</em> or other iterators pointing at the same item as
<em>it</em> are invalidated. Returns an iterator to the next item after
<em>it</em>, or <a href="#end">end</a>() if there is no such item.
<p> This function is provided for STL compatibility. It is equivalent
to <a href="#remove">remove</a>().
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="erase-2"></a>TQValueList::erase ( <a href="ntqvaluelist.html#iterator">iterator</a> first, <a href="ntqvaluelist.html#iterator">iterator</a> last )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Deletes all items from <em>first</em> to <em>last</em> (not including <em>last</em>). No iterators are invalidated, except those pointing to the
removed items themselves. Returns <em>last</em>.
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="find"></a>TQValueList::find ( const T & x )
</h3>
<p> Returns an iterator pointing to the first occurrence of <em>x</em> in
the list.
<p> Returns <a href="#end">end</a>() is no item matched.
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="find-2"></a>TQValueList::find ( const T & x ) const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns an iterator pointing to the first occurrence of <em>x</em> in
the list.
<p> Returns <a href="#end">end</a>() if no item matched.
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="find-3"></a>TQValueList::find ( <a href="ntqvaluelist.html#iterator">iterator</a> it, const T & x )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Finds the first occurrence of <em>x</em> in the list starting at the
position given by <em>it</em>.
<p> Returns <a href="#end">end</a>() if no item matched.
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="find-4"></a>TQValueList::find ( <a href="ntqvaluelist.html#const_iterator">const_iterator</a> it, const T & x ) const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Finds the first occurrence of <em>x</em> in the list starting at the
position given by <em>it</em>.
<p> Returns <a href="#end">end</a>() if no item matched.
<h3 class=fn>int <a name="findIndex"></a>TQValueList::findIndex ( const T & x ) const
</h3>
<p> Returns the index of the first occurrence of the value <em>x</em>.
Returns -1 if no item matched.
<h3 class=fn>T & <a name="first"></a>TQValueList::first ()
</h3>
<p> Returns a reference to the first item. If the list contains no
first item (i.e. <a href="#isEmpty">isEmpty</a>() returns TRUE), the return value is
undefined.
<p> <p>See also <a href="#last">last</a>().
<p>Example: <a href="mail-example.html#x719">network/mail/smtp.cpp</a>.
<h3 class=fn>const T & <a name="first-2"></a>TQValueList::first () const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn><a href="ntqvaluelist.html#const_iterator">const_iterator</a> <a name="fromLast"></a>TQValueList::fromLast () const
</h3>
<p> Returns an iterator to the last item in the list, or <a href="#end">end</a>() if
there is no last item.
<p> Use the end() function instead. For example:
<p> <pre>
TQValueList<int> l;
...
TQValueList<int>::<a href="#iterator">iterator</a> it = l.<a href="#end">end</a>();
--it;
if ( it != <a href="#end">end</a>() )
// ...
</pre>
<p>
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="fromLast-2"></a>TQValueList::fromLast ()
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns an iterator to the last item in the list, or <a href="#end">end</a>() if
there is no last item.
<p> Use the end() function instead. For example:
<p> <pre>
TQValueList<int> l;
...
TQValueList<int>::<a href="#iterator">iterator</a> it = l.<a href="#end">end</a>();
--it;
if ( it != <a href="#end">end</a>() )
// ...
</pre>
<p>
<h3 class=fn><a href="ntqvaluelist.html#reference">reference</a> <a name="front"></a>TQValueList::front ()
</h3>
<p> Returns a reference to the first item. If the list contains no
first item (i.e. <a href="#empty">empty</a>() returns TRUE), the return value is
undefined.
<p> This function is provided for STL compatibility. It is equivalent
to <a href="#first">first</a>().
<p> <p>See also <a href="#back">back</a>().
<h3 class=fn><a href="ntqvaluelist.html#const_reference">const_reference</a> <a name="front-2"></a>TQValueList::front () const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="insert"></a>TQValueList::insert ( <a href="ntqvaluelist.html#iterator">iterator</a> it, const T & x )
</h3>
<p> Inserts the value <em>x</em> in front of the item pointed to by the
iterator, <em>it</em>.
<p> Returns an iterator pointing at the inserted item.
<p> <p>See also <a href="#append">append</a>() and <a href="#prepend">prepend</a>().
<p>Example: <a href="themes-example.html#x346">themes/themes.cpp</a>.
<h3 class=fn>void <a name="insert-2"></a>TQValueList::insert ( <a href="ntqvaluelist.html#iterator">iterator</a> pos, <a href="ntqvaluelist.html#size_type">size_type</a> n, const T & x )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts <em>n</em> copies of <em>x</em> before position <em>pos</em>.
<h3 class=fn>bool <a name="isEmpty"></a>TQValueList::isEmpty () const
</h3>
<p> Returns TRUE if the list contains no items; otherwise returns
FALSE.
<p> <p>See also <a href="#count">count</a>().
<p>Examples: <a href="simple-font-demo-example.html#x2856">fonts/simple-qfont-demo/viewer.cpp</a> and <a href="mail-example.html#x720">network/mail/smtp.cpp</a>.
<h3 class=fn>T & <a name="last"></a>TQValueList::last ()
</h3>
<p> Returns a reference to the last item. If the list contains no last
item (i.e. <a href="#empty">empty</a>() returns TRUE), the return value is undefined.
<h3 class=fn>const T & <a name="last-2"></a>TQValueList::last () const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn>bool <a name="operator!-eq"></a>TQValueList::operator!= ( const <a href="ntqvaluelist.html">TQValueList</a><T> & l ) const
</h3>
<p> Compares both lists.
<p> Returns TRUE if this list and <em>l</em> are unequal; otherwise returns
FALSE.
<h3 class=fn><a href="ntqvaluelist.html">TQValueList</a><T> <a name="operator+"></a>TQValueList::operator+ ( const <a href="ntqvaluelist.html">TQValueList</a><T> & l ) const
</h3>
<p> Creates a new list and fills it with the items of this list. Then
the items of <em>l</em> are appended. Returns the new list.
<h3 class=fn><a href="ntqvaluelist.html">TQValueList</a><T> & <a name="operator+-eq"></a>TQValueList::operator+= ( const <a href="ntqvaluelist.html">TQValueList</a><T> & l )
</h3>
<p> Appends the items of <em>l</em> to this list. Returns a reference to
this list.
<h3 class=fn><a href="ntqvaluelist.html">TQValueList</a><T> & <a name="operator+-eq-2"></a>TQValueList::operator+= ( const T & x )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Appends the value <em>x</em> to the list. Returns a reference to the
list.
<h3 class=fn><a href="ntqvaluelist.html">TQValueList</a><T> & <a name="operator-lt-lt"></a>TQValueList::operator<< ( const T & x )
</h3>
<p> Adds the value <em>x</em> to the end of the list.
<p> Returns a reference to the list.
<h3 class=fn><a href="ntqvaluelist.html">TQValueList</a><T> & <a name="operator-eq"></a>TQValueList::operator= ( const <a href="ntqvaluelist.html">TQValueList</a><T> & l )
</h3>
<p> Assigns <em>l</em> to this list and returns a reference to this list.
<p> All iterators of the current list become invalidated by this
operation. The cost of such an assignment is O(1) since TQValueList
is <a href="shclass.html#implicitly-shared">implicitly shared</a>.
<h3 class=fn><a href="ntqvaluelist.html">TQValueList</a><T> & <a name="operator-eq-2"></a>TQValueList::operator= ( const std::list<T> & l )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Assigns the contents of <em>l</em> to the list.
<p> All iterators of the current list become invalidated by this
operation.
<h3 class=fn>bool <a name="operator-eq-eq"></a>TQValueList::operator== ( const <a href="ntqvaluelist.html">TQValueList</a><T> & l ) const
</h3>
<p> Compares both lists.
<p> Returns TRUE if this list and <em>l</em> are equal; otherwise returns
FALSE.
<h3 class=fn>bool <a name="operator-eq-eq-2"></a>TQValueList::operator== ( const std::list<T> & l ) const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if this list and <em>l</em> are equal; otherwise returns
FALSE.
<p> This operator is provided for compatibility with STL containers.
<h3 class=fn>const T & <a name="operator[]"></a>TQValueList::operator[] ( <a href="ntqvaluelist.html#size_type">size_type</a> i ) const
</h3>
<p> Returns a const reference to the item with index <em>i</em> in the list.
It is up to you to check whether this item really exists. You can
do that easily with the <a href="#count">count</a>() function. However this operator
does not check whether <em>i</em> is in range and will deliver undefined
results if it does not exist.
<p> <b>Warning:</b> This function uses a linear search and can be extremely
slow for large lists. TQValueList is not optimized for random item
access. If you need random access use a different container, such
as <a href="ntqvaluevector.html">TQValueVector</a>.
<h3 class=fn>T & <a name="operator[]-2"></a>TQValueList::operator[] ( <a href="ntqvaluelist.html#size_type">size_type</a> i )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a non-const reference to the item with index <em>i</em>.
<h3 class=fn>void <a name="pop_back"></a>TQValueList::pop_back ()
</h3>
<p> Removes the last item. If there is no last item, this operation is
undefined.
<p> This function is provided for STL compatibility.
<h3 class=fn>void <a name="pop_front"></a>TQValueList::pop_front ()
</h3>
<p> Removes the first item. If there is no first item, this operation
is undefined.
<p> This function is provided for STL compatibility.
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="prepend"></a>TQValueList::prepend ( const T & x )
</h3>
<p> Inserts <em>x</em> at the beginning of the list.
<p> <p>See also <a href="#insert">insert</a>() and <a href="#append">append</a>().
<h3 class=fn>void <a name="push_back"></a>TQValueList::push_back ( const T & x )
</h3>
<p> Inserts <em>x</em> at the end of the list.
<p> This function is provided for STL compatibility. It is equivalent
to <a href="#append">append</a>().
<h3 class=fn>void <a name="push_front"></a>TQValueList::push_front ( const T & x )
</h3>
<p> Inserts <em>x</em> at the beginning of the list.
<p> This function is provided for STL compatibility. It is equivalent
to <a href="#prepend">prepend</a>().
<p>Example: <a href="toplevel-example.html#x2534">toplevel/options.ui.h</a>.
<h3 class=fn><a href="ntqvaluelist.html#iterator">iterator</a> <a name="remove"></a>TQValueList::remove ( <a href="ntqvaluelist.html#iterator">iterator</a> it )
</h3>
<p> Removes the item pointed to by <em>it</em> from the list. No iterators
other than <em>it</em> or other iterators pointing at the same item as
<em>it</em> are invalidated. Returns an iterator to the next item after
<em>it</em>, or <a href="#end">end</a>() if there is no such item.
<p> <p>See also <a href="#clear">clear</a>().
<h3 class=fn>uint <a name="remove-2"></a>TQValueList::remove ( const T & x )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Removes all items that have value <em>x</em> and returns the number of
removed items.
<h3 class=fn><a href="ntqvaluelist.html#size_type">size_type</a> <a name="size"></a>TQValueList::size () const
</h3>
<p> Returns the number of items in the list.
<p> This function is provided for STL compatibility. It is equivalent
to <a href="#count">count</a>().
<p> <p>See also <a href="#empty">empty</a>().
<hr><h2>Related Functions</h2>
<h3 class=fn><a href="ntqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-2"></a>operator<< ( <a href="ntqdatastream.html">TQDataStream</a> & s, const <a href="ntqvaluelist.html">TQValueList</a><T> & l )
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<p> Writes a list, <em>l</em>, to the stream <em>s</em>. The type T stored in the
list must implement the streaming operator.
<h3 class=fn><a href="ntqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="ntqdatastream.html">TQDataStream</a> & s, <a href="ntqvaluelist.html">TQValueList</a><T> & l )
</h3>
<p>
<p> Reads a list, <em>l</em>, from the stream <em>s</em>. The type T stored in the
list must implement the streaming operator.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright © 1995-2007
<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 © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>
|