-rw-r--r-- | qmake/tools/qglist.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/qmake/tools/qglist.cpp b/qmake/tools/qglist.cpp index 155d585..bd27f8a 100644 --- a/qmake/tools/qglist.cpp +++ b/qmake/tools/qglist.cpp | |||
@@ -284,102 +284,98 @@ QGList& QGList::operator=( const QGList &list ) | |||
284 | Compares this list with \a list. Returns TRUE if the lists | 284 | Compares this list with \a list. Returns TRUE if the lists |
285 | contain the same data, otherwise FALSE. | 285 | contain the same data, otherwise FALSE. |
286 | */ | 286 | */ |
287 | 287 | ||
288 | bool QGList::operator==( const QGList &list ) const | 288 | bool QGList::operator==( const QGList &list ) const |
289 | { | 289 | { |
290 | if ( count() != list.count() ) | 290 | if ( count() != list.count() ) |
291 | return FALSE; | 291 | return FALSE; |
292 | 292 | ||
293 | if ( count() == 0 ) | 293 | if ( count() == 0 ) |
294 | return TRUE; | 294 | return TRUE; |
295 | 295 | ||
296 | QLNode *n1 = firstNode; | 296 | QLNode *n1 = firstNode; |
297 | QLNode *n2 = list.firstNode; | 297 | QLNode *n2 = list.firstNode; |
298 | while ( n1 && n2 ) { | 298 | while ( n1 && n2 ) { |
299 | // should be mutable | 299 | // should be mutable |
300 | if ( ( (QGList*)this )->compareItems( n1->data, n2->data ) != 0 ) | 300 | if ( ( (QGList*)this )->compareItems( n1->data, n2->data ) != 0 ) |
301 | return FALSE; | 301 | return FALSE; |
302 | n1 = n1->next; | 302 | n1 = n1->next; |
303 | n2 = n2->next; | 303 | n2 = n2->next; |
304 | } | 304 | } |
305 | 305 | ||
306 | return TRUE; | 306 | return TRUE; |
307 | } | 307 | } |
308 | 308 | ||
309 | /*! | 309 | /*! |
310 | \fn uint QGList::count() const | 310 | \fn uint QGList::count() const |
311 | 311 | ||
312 | Returns the number of items in the list. | 312 | Returns the number of items in the list. |
313 | */ | 313 | */ |
314 | 314 | ||
315 | 315 | ||
316 | /*! | 316 | /*! |
317 | Returns the node at position \a index. Sets this node to current. | 317 | Returns the node at position \a index. Sets this node to current. |
318 | */ | 318 | */ |
319 | 319 | ||
320 | QLNode *QGList::locate( uint index ) | 320 | QLNode *QGList::locate( uint index ) |
321 | { | 321 | { |
322 | if ( index == (uint)curIndex ) // current node ? | 322 | if ( index == (uint)curIndex ) // current node ? |
323 | return curNode; | 323 | return curNode; |
324 | if ( !curNode && firstNode ) { // set current node | 324 | if ( !curNode && firstNode ) { // set current node |
325 | curNode = firstNode; | 325 | curNode = firstNode; |
326 | curIndex = 0; | 326 | curIndex = 0; |
327 | } | 327 | } |
328 | register QLNode *node; | 328 | register QLNode *node; |
329 | int distance = index - curIndex; // node distance to cur node | 329 | int distance = index - curIndex; // node distance to cur node |
330 | bool forward; // direction to traverse | 330 | bool forward; // direction to traverse |
331 | 331 | ||
332 | if ( index >= numNodes ) { | 332 | if ( index >= numNodes ) |
333 | #if defined(QT_CHECK_RANGE) | ||
334 | qWarning( "QGList::locate: Index %d out of range", index ); | ||
335 | #endif | ||
336 | return 0; | 333 | return 0; |
337 | } | ||
338 | 334 | ||
339 | if ( distance < 0 ) | 335 | if ( distance < 0 ) |
340 | distance = -distance; | 336 | distance = -distance; |
341 | if ( (uint)distance < index && (uint)distance < numNodes - index ) { | 337 | if ( (uint)distance < index && (uint)distance < numNodes - index ) { |
342 | node = curNode; // start from current node | 338 | node = curNode; // start from current node |
343 | forward = index > (uint)curIndex; | 339 | forward = index > (uint)curIndex; |
344 | } else if ( index < numNodes - index ) {// start from first node | 340 | } else if ( index < numNodes - index ) {// start from first node |
345 | node = firstNode; | 341 | node = firstNode; |
346 | distance = index; | 342 | distance = index; |
347 | forward = TRUE; | 343 | forward = TRUE; |
348 | } else { // start from last node | 344 | } else { // start from last node |
349 | node = lastNode; | 345 | node = lastNode; |
350 | distance = numNodes - index - 1; | 346 | distance = numNodes - index - 1; |
351 | if ( distance < 0 ) | 347 | if ( distance < 0 ) |
352 | distance = 0; | 348 | distance = 0; |
353 | forward = FALSE; | 349 | forward = FALSE; |
354 | } | 350 | } |
355 | if ( forward ) { // now run through nodes | 351 | if ( forward ) { // now run through nodes |
356 | while ( distance-- ) | 352 | while ( distance-- ) |
357 | node = node->next; | 353 | node = node->next; |
358 | } else { | 354 | } else { |
359 | while ( distance-- ) | 355 | while ( distance-- ) |
360 | node = node->prev; | 356 | node = node->prev; |
361 | } | 357 | } |
362 | curIndex = index; // must update index | 358 | curIndex = index; // must update index |
363 | return curNode = node; | 359 | return curNode = node; |
364 | } | 360 | } |
365 | 361 | ||
366 | 362 | ||
367 | /*! | 363 | /*! |
368 | Inserts item \a d at its sorted position in the list. | 364 | Inserts item \a d at its sorted position in the list. |
369 | */ | 365 | */ |
370 | 366 | ||
371 | void QGList::inSort( QPtrCollection::Item d ) | 367 | void QGList::inSort( QPtrCollection::Item d ) |
372 | { | 368 | { |
373 | int index = 0; | 369 | int index = 0; |
374 | register QLNode *n = firstNode; | 370 | register QLNode *n = firstNode; |
375 | while ( n && compareItems(n->data,d) < 0 ){ // find position in list | 371 | while ( n && compareItems(n->data,d) < 0 ){ // find position in list |
376 | n = n->next; | 372 | n = n->next; |
377 | index++; | 373 | index++; |
378 | } | 374 | } |
379 | insertAt( index, d ); | 375 | insertAt( index, d ); |
380 | } | 376 | } |
381 | 377 | ||
382 | 378 | ||
383 | /*! | 379 | /*! |
384 | Inserts item \a d at the start of the list. | 380 | Inserts item \a d at the start of the list. |
385 | */ | 381 | */ |