source: trunk/doc/html/qvaluelist-h.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 21.8 KB
Line 
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/include/qvaluelist.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qvaluelist.h Include File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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>qvaluelist.h</h1>
33
34<p>This is the verbatim text of the qvaluelist.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qvaluelist-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QValueList class
41**
42** Created : 990406
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the tools module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QVALUELIST_H
75#define QVALUELIST_H
76
77#ifndef QT_H
78#include "qtl.h"
79#include "qshared.h"
80#include "qdatastream.h"
81#endif // QT_H
82
83#ifndef QT_NO_STL
84#include &lt;iterator&gt;
85#include &lt;list&gt;
86#endif
87
88//#define QT_CHECK_VALUELIST_RANGE
89
90#if defined(Q_CC_MSVC)
91#pragma warning(disable:4284) // "return type for operator -&gt; is not a UDT"
92#endif
93
94template &lt;class T&gt;
95class QValueListNode
96{
97public:
98 QValueListNode( const T&amp; t ) : data( t ) { }
99 QValueListNode() { }
100#if defined(Q_TEMPLATEDLL)
101 // Workaround MS bug in memory de/allocation in DLL vs. EXE
102 virtual ~QValueListNode() { }
103#endif
104
105 QValueListNode&lt;T&gt;* next;
106 QValueListNode&lt;T&gt;* prev;
107 T data;
108};
109
110template&lt;class T&gt;
111class QValueListIterator
112{
113 public:
114 /**
115 * Typedefs
116 */
117 typedef QValueListNode&lt;T&gt;* NodePtr;
118#ifndef QT_NO_STL
119 typedef std::bidirectional_iterator_tag iterator_category;
120#endif
121 typedef T value_type;
122 typedef size_t size_type;
123#ifndef QT_NO_STL
124 typedef ptrdiff_t difference_type;
125#else
126 typedef int difference_type;
127#endif
128 typedef T* pointer;
129 typedef T&amp; reference;
130
131 /**
132 * Variables
133 */
134 NodePtr node;
135
136 /**
137 * Functions
138 */
139 QValueListIterator() : node( 0 ) {}
140 QValueListIterator( NodePtr p ) : node( p ) {}
141 QValueListIterator( const QValueListIterator&lt;T&gt;&amp; it ) : node( it.node ) {}
142
143 bool operator==( const QValueListIterator&lt;T&gt;&amp; it ) const { return node == it.node; }
144 bool operator!=( const QValueListIterator&lt;T&gt;&amp; it ) const { return node != it.node; }
145 const T&amp; operator*() const { return node-&gt;data; }
146 T&amp; operator*() { return node-&gt;data; }
147 // UDT for T = x*
148 // T* operator-&gt;() const { return &amp;node-&gt;data; }
149
150 QValueListIterator&lt;T&gt;&amp; operator++() {
151 node = node-&gt;next;
152 return *this;
153 }
154
155 QValueListIterator&lt;T&gt; operator++(int) {
156 QValueListIterator&lt;T&gt; tmp = *this;
157 node = node-&gt;next;
158 return tmp;
159 }
160
161 QValueListIterator&lt;T&gt;&amp; operator--() {
162 node = node-&gt;prev;
163 return *this;
164 }
165
166 QValueListIterator&lt;T&gt; operator--(int) {
167 QValueListIterator&lt;T&gt; tmp = *this;
168 node = node-&gt;prev;
169 return tmp;
170 }
171
172 QValueListIterator&lt;T&gt;&amp; operator+=( int j ) {
173 while ( j-- )
174 node = node-&gt;next;
175 return *this;
176 }
177
178 QValueListIterator&lt;T&gt;&amp; operator-=( int j ) {
179 while ( j-- )
180 node = node-&gt;prev;
181 return *this;
182 }
183
184};
185
186template&lt;class T&gt;
187class QValueListConstIterator
188{
189 public:
190 /**
191 * Typedefs
192 */
193 typedef QValueListNode&lt;T&gt;* NodePtr;
194#ifndef QT_NO_STL
195 typedef std::bidirectional_iterator_tag iterator_category;
196#endif
197 typedef T value_type;
198 typedef size_t size_type;
199#ifndef QT_NO_STL
200 typedef ptrdiff_t difference_type;
201#else
202 typedef int difference_type;
203#endif
204 typedef const T* pointer;
205 typedef const T&amp; reference;
206
207 /**
208 * Variables
209 */
210 NodePtr node;
211
212 /**
213 * Functions
214 */
215 QValueListConstIterator() : node( 0 ) {}
216 QValueListConstIterator( NodePtr p ) : node( p ) {}
217 QValueListConstIterator( const QValueListConstIterator&lt;T&gt;&amp; it ) : node( it.node ) {}
218 QValueListConstIterator( const QValueListIterator&lt;T&gt;&amp; it ) : node( it.node ) {}
219
220 bool operator==( const QValueListConstIterator&lt;T&gt;&amp; it ) const { return node == it.node; }
221 bool operator!=( const QValueListConstIterator&lt;T&gt;&amp; it ) const { return node != it.node; }
222 const T&amp; operator*() const { return node-&gt;data; }
223 // UDT for T = x*
224 // const T* operator-&gt;() const { return &amp;node-&gt;data; }
225
226 QValueListConstIterator&lt;T&gt;&amp; operator++() {
227 node = node-&gt;next;
228 return *this;
229 }
230
231 QValueListConstIterator&lt;T&gt; operator++(int) {
232 QValueListConstIterator&lt;T&gt; tmp = *this;
233 node = node-&gt;next;
234 return tmp;
235 }
236
237 QValueListConstIterator&lt;T&gt;&amp; operator--() {
238 node = node-&gt;prev;
239 return *this;
240 }
241
242 QValueListConstIterator&lt;T&gt; operator--(int) {
243 QValueListConstIterator&lt;T&gt; tmp = *this;
244 node = node-&gt;prev;
245 return tmp;
246 }
247};
248
249template &lt;class T&gt;
250class QValueListPrivate : public QShared
251{
252public:
253 /**
254 * Typedefs
255 */
256 typedef QValueListIterator&lt;T&gt; Iterator;
257 typedef QValueListConstIterator&lt;T&gt; ConstIterator;
258 typedef QValueListNode&lt;T&gt; Node;
259 typedef QValueListNode&lt;T&gt;* NodePtr;
260 typedef size_t size_type;
261
262 /**
263 * Functions
264 */
265 QValueListPrivate();
266 QValueListPrivate( const QValueListPrivate&lt;T&gt;&amp; _p );
267
268 void derefAndDelete() // ### hack to get around hp-cc brain damage
269 {
270 if ( deref() )
271 delete this;
272 }
273
274#if defined(Q_TEMPLATEDLL)
275 // Workaround MS bug in memory de/allocation in DLL vs. EXE
276 virtual
277#endif
278 ~QValueListPrivate();
279
280 Iterator insert( Iterator it, const T&amp; x );
281 Iterator remove( Iterator it );
282 NodePtr find( NodePtr start, const T&amp; x ) const;
283 int findIndex( NodePtr start, const T&amp; x ) const;
284 uint contains( const T&amp; x ) const;
285 uint remove( const T&amp; x );
286 NodePtr at( size_type i ) const;
287 void clear();
288
289 NodePtr node;
290 size_type nodes;
291};
292
293template &lt;class T&gt;
294Q_INLINE_TEMPLATES QValueListPrivate&lt;T&gt;::QValueListPrivate()
295{
296 node = new Node; node-&gt;next = node-&gt;prev = node; nodes = 0;
297}
298
299template &lt;class T&gt;
300Q_INLINE_TEMPLATES QValueListPrivate&lt;T&gt;::QValueListPrivate( const QValueListPrivate&lt;T&gt;&amp; _p )
301 : QShared()
302{
303 node = new Node; node-&gt;next = node-&gt;prev = node; nodes = 0;
304 Iterator b( _p.node-&gt;next );
305 Iterator e( _p.node );
306 Iterator i( node );
307 while( b != e )
308 insert( i, *b++ );
309}
310
311template &lt;class T&gt;
312Q_INLINE_TEMPLATES QValueListPrivate&lt;T&gt;::~QValueListPrivate() {
313 NodePtr p = node-&gt;next;
314 while( p != node ) {
315 NodePtr x = p-&gt;next;
316 delete p;
317 p = x;
318 }
319 delete node;
320}
321
322template &lt;class T&gt;
323Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator QValueListPrivate&lt;T&gt;::insert( Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator it, const T&amp; x )
324{
325 NodePtr p = new Node( x );
326 p-&gt;next = it.node;
327 p-&gt;prev = it.node-&gt;prev;
328 it.node-&gt;prev-&gt;next = p;
329 it.node-&gt;prev = p;
330 nodes++;
331 return p;
332}
333
334template &lt;class T&gt;
335Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator QValueListPrivate&lt;T&gt;::remove( Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator it )
336{
337 Q_ASSERT ( it.node != node );
338 NodePtr next = it.node-&gt;next;
339 NodePtr prev = it.node-&gt;prev;
340 prev-&gt;next = next;
341 next-&gt;prev = prev;
342 delete it.node;
343 nodes--;
344 return Iterator( next );
345}
346
347template &lt;class T&gt;
348Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate&lt;T&gt;::NodePtr QValueListPrivate&lt;T&gt;::find( Q_TYPENAME QValueListPrivate&lt;T&gt;::NodePtr start, const T&amp; x ) const
349{
350 ConstIterator first( start );
351 ConstIterator last( node );
352 while( first != last) {
353 if ( *first == x )
354 return first.node;
355 ++first;
356 }
357 return last.node;
358}
359
360template &lt;class T&gt;
361Q_INLINE_TEMPLATES int QValueListPrivate&lt;T&gt;::findIndex( Q_TYPENAME QValueListPrivate&lt;T&gt;::NodePtr start, const T&amp; x ) const
362{
363 ConstIterator first( start );
364 ConstIterator last( node );
365 int pos = 0;
366 while( first != last) {
367 if ( *first == x )
368 return pos;
369 ++first;
370 ++pos;
371 }
372 return -1;
373}
374
375template &lt;class T&gt;
376Q_INLINE_TEMPLATES uint QValueListPrivate&lt;T&gt;::contains( const T&amp; x ) const
377{
378 uint result = 0;
379 Iterator first = Iterator( node-&gt;next );
380 Iterator last = Iterator( node );
381 while( first != last) {
382 if ( *first == x )
383 ++result;
384 ++first;
385 }
386 return result;
387}
388
389template &lt;class T&gt;
390Q_INLINE_TEMPLATES uint QValueListPrivate&lt;T&gt;::remove( const T&amp; _x )
391{
392 const T x = _x;
393 uint result = 0;
394 Iterator first = Iterator( node-&gt;next );
395 Iterator last = Iterator( node );
396 while( first != last) {
397 if ( *first == x ) {
398 first = remove( first );
399 ++result;
400 } else
401 ++first;
402 }
403 return result;
404}
405
406template &lt;class T&gt;
407Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate&lt;T&gt;::NodePtr QValueListPrivate&lt;T&gt;::at( size_type i ) const
408{
409 Q_ASSERT( i &lt;= nodes );
410 NodePtr p = node-&gt;next;
411 for( size_type x = 0; x &lt; i; ++x )
412 p = p-&gt;next;
413 return p;
414}
415
416template &lt;class T&gt;
417Q_INLINE_TEMPLATES void QValueListPrivate&lt;T&gt;::clear()
418{
419 nodes = 0;
420 NodePtr p = node-&gt;next;
421 while( p != node ) {
422 NodePtr next = p-&gt;next;
423 delete p;
424 p = next;
425 }
426 node-&gt;next = node-&gt;prev = node;
427}
428
429#ifdef QT_CHECK_RANGE
430# if !defined( QT_NO_DEBUG ) &amp;&amp; defined( QT_CHECK_VALUELIST_RANGE )
431# define QT_CHECK_INVALID_LIST_ELEMENT if ( empty() ) qWarning( "QValueList: Warning invalid element" )
432# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL Q_ASSERT( !empty() );
433# else
434# define QT_CHECK_INVALID_LIST_ELEMENT
435# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL
436# endif
437#else
438# define QT_CHECK_INVALID_LIST_ELEMENT
439# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL
440#endif
441
442template &lt;class T&gt; class QDeepCopy;
443
444template &lt;class T&gt;
445class QValueList
446{
447public:
448 /**
449 * Typedefs
450 */
451 typedef QValueListIterator&lt;T&gt; iterator;
452 typedef QValueListConstIterator&lt;T&gt; const_iterator;
453 typedef T value_type;
454 typedef value_type* pointer;
455 typedef const value_type* const_pointer;
456 typedef value_type&amp; reference;
457 typedef const value_type&amp; const_reference;
458 typedef size_t size_type;
459#ifndef QT_NO_STL
460 typedef ptrdiff_t difference_type;
461#else
462 typedef int difference_type;
463#endif
464
465 /**
466 * API
467 */
468 QValueList() { sh = new QValueListPrivate&lt;T&gt;; }
469 QValueList( const QValueList&lt;T&gt;&amp; l ) { sh = l.sh; sh-&gt;ref(); }
470#ifndef QT_NO_STL
471 QValueList( const std::list&lt;T&gt;&amp; l )
472 {
473 sh = new QValueListPrivate&lt;T&gt;;
474 qCopy( l.begin(), l.end(), std::back_inserter( *this ) );
475 }
476#endif
477 ~QValueList() { sh-&gt;derefAndDelete(); }
478
479 QValueList&lt;T&gt;&amp; operator= ( const QValueList&lt;T&gt;&amp; l )
480 {
481 l.sh-&gt;ref();
482 sh-&gt;derefAndDelete();
483 sh = l.sh;
484 return *this;
485 }
486#ifndef QT_NO_STL
487 QValueList&lt;T&gt;&amp; operator= ( const std::list&lt;T&gt;&amp; l )
488 {
489 detach();
490 qCopy( l.begin(), l.end(), std::back_inserter( *this ) );
491 return *this;
492 }
493 bool operator== ( const std::list&lt;T&gt;&amp; l ) const
494 {
495 if ( size() != l.size() )
496 return FALSE;
497 const_iterator it2 = begin();
498#if !defined(Q_CC_MIPS)
499 typename
500#endif
501 std::list&lt;T&gt;::const_iterator it = l.begin();
502 for ( ; it2 != end(); ++it2, ++it )
503 if ( !((*it2) == (*it)) )
504 return FALSE;
505 return TRUE;
506 }
507#endif
508 bool operator== ( const QValueList&lt;T&gt;&amp; l ) const;
509 bool operator!= ( const QValueList&lt;T&gt;&amp; l ) const { return !( *this == l ); }
510 iterator begin() { detach(); return iterator( sh-&gt;node-&gt;next ); }
511 const_iterator begin() const { return const_iterator( sh-&gt;node-&gt;next ); }
512 const_iterator constBegin() const { return const_iterator( sh-&gt;node-&gt;next ); }
513 iterator end() { detach(); return iterator( sh-&gt;node ); }
514 const_iterator end() const { return const_iterator( sh-&gt;node ); }
515 const_iterator constEnd() const { return const_iterator( sh-&gt;node ); }
516 iterator insert( iterator it, const T&amp; x ) { detach(); return sh-&gt;insert( it, x ); }
517 uint remove( const T&amp; x ) { detach(); return sh-&gt;remove( x ); }
518 void clear();
519
520 // ### 4.0: move out of class
521 QValueList&lt;T&gt;&amp; operator&lt;&lt; ( const T&amp; x )
522 {
523 append( x );
524 return *this;
525 }
526
527 size_type size() const { return sh-&gt;nodes; }
528 bool empty() const { return sh-&gt;nodes == 0; }
529 void push_front( const T&amp; x ) { detach(); sh-&gt;insert( begin(), x ); }
530 void push_back( const T&amp; x ) { detach(); sh-&gt;insert( end(), x ); }
531 iterator erase( iterator pos ) { detach(); return sh-&gt;remove( pos ); }
532 iterator erase( iterator first, iterator last );
533 reference front() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); }
534 const_reference front() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); }
535 reference back() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); }
536 const_reference back() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); }
537 void pop_front() { QT_CHECK_INVALID_LIST_ELEMENT; erase( begin() ); }
538 void pop_back() {
539 QT_CHECK_INVALID_LIST_ELEMENT;
540 iterator tmp = end();
541 erase( --tmp );
542 }
543 void insert( iterator pos, size_type n, const T&amp; x );
544 // Some compilers (incl. vc++) would instantiate this function even if
545 // it is not used; this would constrain QValueList to classes that provide
546 // an operator&lt;
547 /*
548 void sort()
549 {
550 qHeapSort( *this );
551 }
552 */
553
554 QValueList&lt;T&gt; operator+ ( const QValueList&lt;T&gt;&amp; l ) const;
555 QValueList&lt;T&gt;&amp; operator+= ( const QValueList&lt;T&gt;&amp; l );
556
557 iterator fromLast() { detach(); return iterator( sh-&gt;node-&gt;prev ); }
558 const_iterator fromLast() const { return const_iterator( sh-&gt;node-&gt;prev ); }
559
560 bool isEmpty() const { return ( sh-&gt;nodes == 0 ); }
561
562 iterator append( const T&amp; x ) { detach(); return sh-&gt;insert( end(), x ); }
563 iterator prepend( const T&amp; x ) { detach(); return sh-&gt;insert( begin(), x ); }
564
565 iterator remove( iterator it ) { detach(); return sh-&gt;remove( it ); }
566
567 T&amp; first() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh-&gt;node-&gt;next-&gt;data; }
568 const T&amp; first() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh-&gt;node-&gt;next-&gt;data; }
569 T&amp; last() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh-&gt;node-&gt;prev-&gt;data; }
570 const T&amp; last() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh-&gt;node-&gt;prev-&gt;data; }
571
572 T&amp; operator[] ( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh-&gt;at(i)-&gt;data; }
573 const T&amp; operator[] ( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return sh-&gt;at(i)-&gt;data; }
574 iterator at( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return iterator( sh-&gt;at(i) ); }
575 const_iterator at( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return const_iterator( sh-&gt;at(i) ); }
576 iterator find ( const T&amp; x ) { detach(); return iterator( sh-&gt;find( sh-&gt;node-&gt;next, x) ); }
577 const_iterator find ( const T&amp; x ) const { return const_iterator( sh-&gt;find( sh-&gt;node-&gt;next, x) ); }
578 iterator find ( iterator it, const T&amp; x ) { detach(); return iterator( sh-&gt;find( it.node, x ) ); }
579 const_iterator find ( const_iterator it, const T&amp; x ) const { return const_iterator( sh-&gt;find( it.node, x ) ); }
580 int findIndex( const T&amp; x ) const { return sh-&gt;findIndex( sh-&gt;node-&gt;next, x) ; }
581 size_type contains( const T&amp; x ) const { return sh-&gt;contains( x ); }
582
583 size_type count() const { return sh-&gt;nodes; }
584
585 QValueList&lt;T&gt;&amp; operator+= ( const T&amp; x )
586 {
587 append( x );
588 return *this;
589 }
590 typedef QValueListIterator&lt;T&gt; Iterator;
591 typedef QValueListConstIterator&lt;T&gt; ConstIterator;
592 typedef T ValueType;
593
594protected:
595 /**
596 * Helpers
597 */
598 void detach() { if ( sh-&gt;count &gt; 1 ) detachInternal(); }
599
600 /**
601 * Variables
602 */
603 QValueListPrivate&lt;T&gt;* sh;
604
605private:
606 void detachInternal();
607
608 friend class QDeepCopy&lt; QValueList&lt;T&gt; &gt;;
609};
610
611template &lt;class T&gt;
612Q_INLINE_TEMPLATES bool QValueList&lt;T&gt;::operator== ( const QValueList&lt;T&gt;&amp; l ) const
613{
614 if ( size() != l.size() )
615 return FALSE;
616 const_iterator it2 = begin();
617 const_iterator it = l.begin();
618 for( ; it != l.end(); ++it, ++it2 )
619 if ( !( *it == *it2 ) )
620 return FALSE;
621 return TRUE;
622}
623
624template &lt;class T&gt;
625Q_INLINE_TEMPLATES void QValueList&lt;T&gt;::clear()
626{
627 if ( sh-&gt;count == 1 ) sh-&gt;clear(); else { sh-&gt;deref(); sh = new QValueListPrivate&lt;T&gt;; }
628}
629
630template &lt;class T&gt;
631Q_INLINE_TEMPLATES Q_TYPENAME QValueList&lt;T&gt;::iterator QValueList&lt;T&gt;::erase( Q_TYPENAME QValueList&lt;T&gt;::iterator first, Q_TYPENAME QValueList&lt;T&gt;::iterator last )
632{
633 while ( first != last )
634 erase( first++ );
635 return last;
636}
637
638
639template &lt;class T&gt;
640Q_INLINE_TEMPLATES void QValueList&lt;T&gt;::insert( Q_TYPENAME QValueList&lt;T&gt;::iterator pos, size_type n, const T&amp; x )
641{
642 for ( ; n &gt; 0; --n )
643 insert( pos, x );
644}
645
646template &lt;class T&gt;
647Q_INLINE_TEMPLATES QValueList&lt;T&gt; QValueList&lt;T&gt;::operator+ ( const QValueList&lt;T&gt;&amp; l ) const
648{
649 QValueList&lt;T&gt; l2( *this );
650 for( const_iterator it = l.begin(); it != l.end(); ++it )
651 l2.append( *it );
652 return l2;
653}
654
655template &lt;class T&gt;
656Q_INLINE_TEMPLATES QValueList&lt;T&gt;&amp; QValueList&lt;T&gt;::operator+= ( const QValueList&lt;T&gt;&amp; l )
657{
658 QValueList&lt;T&gt; copy = l;
659 for( const_iterator it = copy.begin(); it != copy.end(); ++it )
660 append( *it );
661 return *this;
662}
663
664template &lt;class T&gt;
665Q_INLINE_TEMPLATES void QValueList&lt;T&gt;::detachInternal()
666{
667 sh-&gt;deref(); sh = new QValueListPrivate&lt;T&gt;( *sh );
668}
669
670#ifndef QT_NO_DATASTREAM
671template &lt;class T&gt;
672Q_INLINE_TEMPLATES QDataStream&amp; operator&gt;&gt;( QDataStream&amp; s, QValueList&lt;T&gt;&amp; l )
673{
674 l.clear();
675 Q_UINT32 c;
676 s &gt;&gt; c;
677 for( Q_UINT32 i = 0; i &lt; c; ++i )
678 {
679 T t;
680 s &gt;&gt; t;
681 l.append( t );
682 if ( s.atEnd() )
683 break;
684 }
685 return s;
686}
687
688template &lt;class T&gt;
689Q_INLINE_TEMPLATES QDataStream&amp; operator&lt;&lt;( QDataStream&amp; s, const QValueList&lt;T&gt;&amp; l )
690{
691 s &lt;&lt; (Q_UINT32)l.size();
692 QValueListConstIterator&lt;T&gt; it = l.begin();
693 for( ; it != l.end(); ++it )
694 s &lt;&lt; *it;
695 return s;
696}
697#endif // QT_NO_DATASTREAM
698
699#define Q_DEFINED_QVALUELIST
700#define Q_DEFINED_QVALUELIST
701#include "qwinexport.h"
702#endif // QVALUELIST_H
703</pre>
704<!-- eof -->
705<p><address><hr><div align=center>
706<table width=100% cellspacing=0 border=0><tr>
707<td>Copyright &copy; 2007
708<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
709<td align=right><div align=right>Qt 3.3.8</div>
710</table></div></address></body>
711</html>
Note: See TracBrowser for help on using the repository browser.