43 #include "qdatastream.h" 46 #if defined(_CC_MSVC_) 47 #pragma warning(disable:4284) // "return type for operator -> is not a UDT" 56 #if defined(Q_TEMPLATEDLL) 89 const T& operator*()
const {
return node->data; }
90 T& operator*() {
return node->data; }
142 const T& operator*()
const {
return node->data; }
187 node =
new Node; node->next = node->prev = node; nodes = 0;
188 Iterator b( _p.node->next );
189 Iterator e( _p.node );
195 void derefAndDelete()
201 #if defined(Q_TEMPLATEDLL) 206 NodePtr p = node->next;
215 Iterator insert( Iterator it,
const T& x ) {
216 NodePtr p =
new Node( x );
218 p->prev = it.
node->prev;
219 it.
node->prev->next = p;
225 Iterator
remove( Iterator it ) {
226 ASSERT ( it.
node != node );
227 NodePtr next = it.
node->next;
228 NodePtr prev = it.
node->prev;
233 return Iterator( next );
236 NodePtr find( NodePtr start,
const T& x )
const {
237 ConstIterator first( start );
238 ConstIterator last( node );
239 while( first != last) {
247 int findIndex( NodePtr start,
const T& x )
const {
248 ConstIterator first( start );
249 ConstIterator last( node );
251 while( first != last) {
260 uint contains(
const T& x )
const {
262 Iterator first = Iterator( node->next );
263 Iterator last = Iterator( node );
264 while( first != last) {
272 void remove(
const T& x ) {
273 Iterator first = Iterator( node->next );
274 Iterator last = Iterator( node );
275 while( first != last) {
277 first =
remove( first );
283 NodePtr at( uint i )
const {
284 ASSERT( i <= nodes );
285 NodePtr p = node->next;
286 for( uint x = 0; x < i; ++x )
293 NodePtr p = node->next;
295 NodePtr next = p->next;
299 node->next = node->prev = node;
327 sh->derefAndDelete();
335 for( ConstIterator it = l.begin(); it != l.end(); ++it )
342 for( ConstIterator it = l.begin(); it != l.end(); ++it )
349 if ( count() != l.count() )
351 ConstIterator it2 = begin();
352 ConstIterator it = l.begin();
353 for( ; it != l.end(); ++it, ++it2 )
354 if ( !( *it == *it2 ) )
359 bool operator!= (
const QValueList<T>& l )
const {
return !( *
this == l ); }
361 Iterator begin() { detach();
return Iterator( sh->node->next ); }
362 ConstIterator begin()
const {
return ConstIterator( sh->node->next ); }
363 Iterator end() { detach();
return Iterator( sh->node ); }
364 ConstIterator end()
const {
return ConstIterator( sh->node ); }
365 Iterator fromLast() { detach();
return Iterator( sh->node->prev ); }
366 ConstIterator fromLast()
const {
return ConstIterator( sh->node->prev ); }
368 bool isEmpty()
const {
return ( sh->nodes == 0 ); }
370 Iterator insert( Iterator it,
const T& x ) { detach();
return sh->insert( it, x ); }
372 Iterator append(
const T& x ) { detach();
return sh->insert( end(), x ); }
373 Iterator prepend(
const T& x ) { detach();
return sh->insert( begin(), x ); }
375 Iterator
remove( Iterator it ) { detach();
return sh->remove( it ); }
376 void remove(
const T& x ) { detach(); sh->remove( x ); }
378 T& first() { detach();
return sh->node->next->data; }
379 const T& first()
const {
return sh->node->next->data; }
380 T& last() { detach();
return sh->node->prev->data; }
381 const T& last()
const {
return sh->node->prev->data; }
383 T& operator[] ( uint i ) { detach();
return sh->at(i)->data; }
384 const T& operator[] ( uint i )
const {
return sh->at(i)->data; }
385 Iterator at( uint i ) { detach();
return Iterator( sh->at(i) ); }
386 ConstIterator at( uint i )
const {
return ConstIterator( sh->at(i) ); }
387 Iterator find (
const T& x ) { detach();
return Iterator( sh->find( sh->node->next, x) ); }
388 ConstIterator find (
const T& x )
const {
return ConstIterator( sh->find( sh->node->next, x) ); }
389 Iterator find ( Iterator it,
const T& x ) { detach();
return Iterator( sh->find( it.
node, x ) ); }
390 ConstIterator find ( ConstIterator it,
const T& x )
const {
return ConstIterator( sh->find( it.
node, x ) ); }
391 int findIndex(
const T& x )
const {
return sh->findIndex( sh->node->next, x) ; }
392 uint contains(
const T& x )
const {
return sh->contains( x ); }
394 uint count()
const {
return sh->nodes; }
396 void clear() {
if ( sh->count == 1 ) sh->clear();
else { sh->deref(); sh =
new QValueListPrivate<T>; } }
423 #ifndef QT_NO_DATASTREAM 430 for( Q_UINT32 i = 0; i < c; ++i )
440 inline QDataStream& operator<<( QDataStream& s, const QValueList<T>& l )
442 s << (Q_UINT32)l.count();
444 for( ; it != l.end(); ++it )
448 #endif // QT_NO_DATASTREAM 449 #endif // QVALUELIST_H Definition: qvaluelist.h:119
void detach()
Helpers.
Definition: qvaluelist.h:415
QValueListPrivate()
Functions.
Definition: qvaluelist.h:185
QValueListIterator< T > Iterator
Typedefs.
Definition: qvaluelist.h:313
NodePtr node
Variables.
Definition: qvaluelist.h:130
Definition: qvaluelist.h:171
QValueListPrivate< T > * sh
Variables.
Definition: qvaluelist.h:420
QValueListIterator< T > Iterator
Typedefs.
Definition: qvaluelist.h:177
QValueListNode< T > * NodePtr
Typedefs.
Definition: qvaluelist.h:125
QValueList()
API.
Definition: qvaluelist.h:320
Definition: qvaluelist.h:67
Definition: qvaluelist.h:307
QValueListIterator()
Functions.
Definition: qvaluelist.h:83
QValueListConstIterator()
Functions.
Definition: qvaluelist.h:135
The QShared struct is internally used for implementing shared classes.
Definition: qshared.h:46
QValueListNode< T > * NodePtr
Typedefs.
Definition: qvaluelist.h:73
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:47
NodePtr node
Variables.
Definition: qvaluelist.h:78
Definition: qvaluelist.h:51