diff options
Diffstat (limited to 'src/tools/qglist.cpp')
-rw-r--r-- | src/tools/qglist.cpp | 182 |
1 files changed, 91 insertions, 91 deletions
diff --git a/src/tools/qglist.cpp b/src/tools/qglist.cpp index c8ed5a6..fb94427 100644 --- a/src/tools/qglist.cpp +++ b/src/tools/qglist.cpp @@ -43,9 +43,9 @@ #include "qdatastream.h" #include "qvaluelist.h" -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) #include "qmutex.h" -#endif // defined(TQT_THREAD_SUPPORT) +#endif // defined(QT_THREAD_SUPPORT) /*! \class QLNode qglist.h @@ -225,7 +225,7 @@ QDataStream &QGList::write( QDataStream &s, QPtrCollection::Item ) const QGList::QGList() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex = new QMutex(true); #endif firstNode = lastNode = curNode = 0; // initialize list @@ -241,7 +241,7 @@ QGList::QGList() QGList::QGList( const QGList & list ) : QPtrCollection( list ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex = new QMutex(true); #endif firstNode = lastNode = curNode = 0; // initialize list @@ -268,7 +268,7 @@ QGList::~QGList() // twice on the same address! This is insane but let's try not to crash // here. iterators = 0; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //delete mutex; #endif } @@ -337,11 +337,11 @@ bool QGList::operator==( const QGList &list ) const QLNode *QGList::locate( uint index ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( index == (uint)curIndex ) { // current node ? -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return curNode; @@ -355,7 +355,7 @@ QLNode *QGList::locate( uint index ) bool forward; // direction to traverse if ( index >= numNodes ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -388,7 +388,7 @@ QLNode *QGList::locate( uint index ) } } curIndex = index; // must update index -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return curNode = node; @@ -401,7 +401,7 @@ QLNode *QGList::locate( uint index ) void QGList::inSort( QPtrCollection::Item d ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif int index = 0; @@ -411,7 +411,7 @@ void QGList::inSort( QPtrCollection::Item d ) index++; } insertAt( index, d ); -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } @@ -423,7 +423,7 @@ void QGList::inSort( QPtrCollection::Item d ) void QGList::prepend( QPtrCollection::Item d ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif register QLNode *n = new QLNode( newItem(d) ); @@ -436,7 +436,7 @@ void QGList::prepend( QPtrCollection::Item d ) firstNode = curNode = n; // curNode affected numNodes++; curIndex = 0; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } @@ -448,7 +448,7 @@ void QGList::prepend( QPtrCollection::Item d ) void QGList::append( QPtrCollection::Item d ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif register QLNode *n = new QLNode( newItem(d) ); @@ -463,7 +463,7 @@ void QGList::append( QPtrCollection::Item d ) lastNode = curNode = n; // curNode affected curIndex = numNodes; numNodes++; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } @@ -475,26 +475,26 @@ void QGList::append( QPtrCollection::Item d ) bool QGList::insertAt( uint index, QPtrCollection::Item d ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( index == 0 ) { prepend( d ); -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; } else if ( index == numNodes ) { append( d ); -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; } QLNode *nextNode = locate( index ); if ( !nextNode ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; @@ -509,7 +509,7 @@ bool QGList::insertAt( uint index, QPtrCollection::Item d ) n->next = nextNode; curNode = n; // curIndex set by locate() numNodes++; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; @@ -522,11 +522,11 @@ bool QGList::insertAt( uint index, QPtrCollection::Item d ) void QGList::relinkNode( QLNode *n ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( n == firstNode ) { // already first -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return; @@ -543,7 +543,7 @@ void QGList::relinkNode( QLNode *n ) firstNode = curNode = n; // curNode affected numNodes++; curIndex = 0; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } @@ -555,11 +555,11 @@ void QGList::relinkNode( QLNode *n ) QLNode *QGList::unlink() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( curNode == 0 ) { // null current node -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -593,7 +593,7 @@ QLNode *QGList::unlink() iterators->notifyRemove( n, curNode ); } numNodes--; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return n; @@ -606,7 +606,7 @@ QLNode *QGList::unlink() bool QGList::removeNode( QLNode *n ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif #if defined(QT_CHECK_NULL) @@ -622,7 +622,7 @@ bool QGList::removeNode( QLNode *n ) delete n; curNode = firstNode; curIndex = curNode ? 0 : -1; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; @@ -636,25 +636,25 @@ bool QGList::removeNode( QLNode *n ) bool QGList::remove( QPtrCollection::Item d ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( d && find(d) == -1 ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; } QLNode *n = unlink(); if ( !n ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; } deleteItem( n->data ); delete n; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; @@ -666,25 +666,25 @@ bool QGList::remove( QPtrCollection::Item d ) bool QGList::removeRef( QPtrCollection::Item d ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( findRef(d) == -1 ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; } QLNode *n = unlink(); if ( !n ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; } deleteItem( n->data ); delete n; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; @@ -708,25 +708,25 @@ bool QGList::removeRef( QPtrCollection::Item d ) bool QGList::removeAt( uint index ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( !locate(index) ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; } QLNode *n = unlink(); if ( !n ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; } deleteItem( n->data ); delete n; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; @@ -738,12 +738,12 @@ bool QGList::removeAt( uint index ) */ bool QGList::replaceAt( uint index, QPtrCollection::Item d ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif QLNode *n = locate( index ); if ( !n ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return FALSE; @@ -752,7 +752,7 @@ bool QGList::replaceAt( uint index, QPtrCollection::Item d ) deleteItem( n->data ); n->data = newItem( d ); } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return TRUE; @@ -766,14 +766,14 @@ bool QGList::replaceAt( uint index, QPtrCollection::Item d ) QPtrCollection::Item QGList::takeNode( QLNode *n ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif #if defined(QT_CHECK_NULL) if ( n == 0 || (n->prev && n->prev->next != n) || (n->next && n->next->prev != n) ) { qWarning( "QGList::takeNode: Corrupted node" ); -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -785,7 +785,7 @@ QPtrCollection::Item QGList::takeNode( QLNode *n ) delete n; // delete the node, not data curNode = firstNode; curIndex = curNode ? 0 : -1; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return d; @@ -797,13 +797,13 @@ QPtrCollection::Item QGList::takeNode( QLNode *n ) QPtrCollection::Item QGList::take() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif QLNode *n = unlink(); // unlink node Item d = n ? n->data : 0; delete n; // delete node, keep contents -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return d; @@ -815,11 +815,11 @@ QPtrCollection::Item QGList::take() QPtrCollection::Item QGList::takeAt( uint index ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( !locate(index) ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -827,7 +827,7 @@ QPtrCollection::Item QGList::takeAt( uint index ) QLNode *n = unlink(); // unlink node Item d = n ? n->data : 0; delete n; // delete node, keep contents -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return d; @@ -839,14 +839,14 @@ QPtrCollection::Item QGList::takeAt( uint index ) QPtrCollection::Item QGList::takeFirst() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif first(); QLNode *n = unlink(); // unlink node Item d = n ? n->data : 0; delete n; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return d; @@ -858,14 +858,14 @@ QPtrCollection::Item QGList::takeFirst() QPtrCollection::Item QGList::takeLast() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif last(); QLNode *n = unlink(); // unlink node Item d = n ? n->data : 0; delete n; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return d; @@ -878,7 +878,7 @@ QPtrCollection::Item QGList::takeLast() void QGList::clear() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif register QLNode *n = firstNode; @@ -898,7 +898,7 @@ void QGList::clear() n = n->next; delete prevNode; // deallocate node } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } @@ -911,7 +911,7 @@ void QGList::clear() int QGList::findRef( QPtrCollection::Item d, bool fromStart ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif register QLNode *n; @@ -929,7 +929,7 @@ int QGList::findRef( QPtrCollection::Item d, bool fromStart ) } curNode = n; curIndex = n ? index : -1; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return curIndex; // return position of item @@ -943,7 +943,7 @@ int QGList::findRef( QPtrCollection::Item d, bool fromStart ) int QGList::find( QPtrCollection::Item d, bool fromStart ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif register QLNode *n; @@ -961,7 +961,7 @@ int QGList::find( QPtrCollection::Item d, bool fromStart ) } curNode = n; curIndex = n ? index : -1; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return curIndex; // return position of item @@ -974,7 +974,7 @@ int QGList::find( QPtrCollection::Item d, bool fromStart ) uint QGList::containsRef( QPtrCollection::Item d ) const { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif register QLNode *n = firstNode; @@ -984,7 +984,7 @@ uint QGList::containsRef( QPtrCollection::Item d ) const count++; n = n->next; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return count; @@ -997,7 +997,7 @@ uint QGList::containsRef( QPtrCollection::Item d ) const uint QGList::contains( QPtrCollection::Item d ) const { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif register QLNode *n = firstNode; @@ -1008,7 +1008,7 @@ uint QGList::contains( QPtrCollection::Item d ) const count++; n = n->next; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return count; @@ -1058,17 +1058,17 @@ uint QGList::contains( QPtrCollection::Item d ) const QPtrCollection::Item QGList::first() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( firstNode ) { curIndex = 0; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return (curNode=firstNode)->data; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -1080,17 +1080,17 @@ QPtrCollection::Item QGList::first() QPtrCollection::Item QGList::last() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( lastNode ) { curIndex = numNodes-1; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return (curNode=lastNode)->data; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -1102,14 +1102,14 @@ QPtrCollection::Item QGList::last() QPtrCollection::Item QGList::next() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( curNode ) { if ( curNode->next ) { curIndex++; curNode = curNode->next; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return curNode->data; @@ -1117,7 +1117,7 @@ QPtrCollection::Item QGList::next() curIndex = -1; curNode = 0; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -1129,14 +1129,14 @@ QPtrCollection::Item QGList::next() QPtrCollection::Item QGList::prev() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif if ( curNode ) { if ( curNode->prev ) { curIndex--; curNode = curNode->prev; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return curNode->data; @@ -1144,7 +1144,7 @@ QPtrCollection::Item QGList::prev() curIndex = -1; curNode = 0; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return 0; @@ -1157,12 +1157,12 @@ QPtrCollection::Item QGList::prev() void QGList::toVector( QGVector *vector ) const { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif vector->clear(); if ( !vector->resize( count() ) ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return; @@ -1174,14 +1174,14 @@ void QGList::toVector( QGVector *vector ) const n = n->next; i++; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } void QGList::heapSortPushDown( QPtrCollection::Item* heap, int first, int last ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif int r = first; @@ -1218,7 +1218,7 @@ void QGList::heapSortPushDown( QPtrCollection::Item* heap, int first, int last ) } } } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } @@ -1233,12 +1233,12 @@ void QGList::heapSortPushDown( QPtrCollection::Item* heap, int first, int last ) void QGList::sort() { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif uint n = count(); if ( n < 2 ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return; @@ -1273,7 +1273,7 @@ void QGList::sort() } delete [] realheap; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif } @@ -1300,7 +1300,7 @@ QDataStream &operator<<( QDataStream &s, const QGList &list ) QDataStream &QGList::read( QDataStream &s ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif uint num; @@ -1326,7 +1326,7 @@ QDataStream &QGList::read( QDataStream &s ) } curNode = firstNode; curIndex = curNode ? 0 : -1; -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return s; @@ -1338,7 +1338,7 @@ QDataStream &QGList::read( QDataStream &s ) QDataStream &QGList::write( QDataStream &s ) const { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif s << count(); // write number of items @@ -1347,7 +1347,7 @@ QDataStream &QGList::write( QDataStream &s ) const write( s, n->data ); n = n->next; } -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return s; @@ -1361,13 +1361,13 @@ QDataStream &QGList::write( QDataStream &s ) const */ QLNode* QGList::erase( QLNode* it ) { -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->lock(); #endif QLNode* n = it; it = it->next; removeNode( n ); -#if defined(TQT_THREAD_SUPPORT) +#if defined(QT_THREAD_SUPPORT) //mutex->unlock(); #endif return it; |