author | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
commit | 155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff) | |
tree | e6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/tools/qgvector.cpp | |
parent | 86703e8a5527ef114facd02c005b6b3a7e62e263 (diff) | |
download | opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2 |
update qmake to 1.05a
-rw-r--r-- | qmake/tools/qgvector.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/qmake/tools/qgvector.cpp b/qmake/tools/qgvector.cpp index 1985f03..3c903ed 100644 --- a/qmake/tools/qgvector.cpp +++ b/qmake/tools/qgvector.cpp | |||
@@ -6,64 +6,70 @@ | |||
6 | ** Created : 930907 | 6 | ** Created : 930907 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the tools module of the Qt GUI Toolkit. | 10 | ** This file is part of the tools module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 12 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | #include "qglobal.h" | ||
39 | #if defined(Q_CC_BOR) | ||
40 | // needed for qsort() because of a std namespace problem on Borland | ||
41 | #include "qplatformdefs.h" | ||
42 | #endif | ||
43 | |||
38 | #define QGVECTOR_CPP | 44 | #define QGVECTOR_CPP |
39 | #include "qgvector.h" | 45 | #include "qgvector.h" |
40 | #include "qglist.h" | 46 | #include "qglist.h" |
41 | #include "qstring.h" | 47 | #include "qstring.h" |
42 | #include "qdatastream.h" | 48 | #include "qdatastream.h" |
43 | #include <stdlib.h> | 49 | #include <stdlib.h> |
44 | 50 | ||
45 | #ifdef QT_THREAD_SUPPORT | 51 | #ifdef QT_THREAD_SUPPORT |
46 | # include <private/qmutexpool_p.h> | 52 | # include <private/qmutexpool_p.h> |
47 | #endif // QT_THREAD_SUPPORT | 53 | #endif // QT_THREAD_SUPPORT |
48 | 54 | ||
49 | #define USE_MALLOC // comment to use new/delete | 55 | #define USE_MALLOC // comment to use new/delete |
50 | 56 | ||
51 | #undef NEW | 57 | #undef NEW |
52 | #undef DELETE | 58 | #undef DELETE |
53 | 59 | ||
54 | #if defined(USE_MALLOC) | 60 | #if defined(USE_MALLOC) |
55 | #define NEW(type,size)((type*)malloc(size*sizeof(type))) | 61 | #define NEW(type,size)((type*)malloc(size*sizeof(type))) |
56 | #define DELETE(array)(free((char*)array)) | 62 | #define DELETE(array)(free((char*)array)) |
57 | #else | 63 | #else |
58 | #define NEW(type,size)(new type[size]) | 64 | #define NEW(type,size)(new type[size]) |
59 | #define DELETE(array)(delete[] array) | 65 | #define DELETE(array)(delete[] array) |
60 | #define DONT_USE_REALLOC // comment to use realloc() | 66 | #define DONT_USE_REALLOC // comment to use realloc() |
61 | #endif | 67 | #endif |
62 | 68 | ||
63 | /*! | 69 | /*! |
64 | \class QGVector | 70 | \class QGVector |
65 | \reentrant | 71 | \reentrant |
66 | \ingroup collection | 72 | \ingroup collection |
67 | 73 | ||
68 | \brief The QGVector class is an internal class for implementing Qt | 74 | \brief The QGVector class is an internal class for implementing Qt |
69 | collection classes. | 75 | collection classes. |
@@ -364,65 +370,66 @@ static int cmp_vec( const void *n1, const void *n2 ) | |||
364 | #endif | 370 | #endif |
365 | { | 371 | { |
366 | return sort_vec->compareItems( *((QPtrCollection::Item*)n1), *((QPtrCollection::Item*)n2) ); | 372 | return sort_vec->compareItems( *((QPtrCollection::Item*)n1), *((QPtrCollection::Item*)n2) ); |
367 | } | 373 | } |
368 | 374 | ||
369 | #if defined(Q_C_CALLBACKS) | 375 | #if defined(Q_C_CALLBACKS) |
370 | } | 376 | } |
371 | #endif | 377 | #endif |
372 | 378 | ||
373 | 379 | ||
374 | void QGVector::sort() // sort vector | 380 | void QGVector::sort() // sort vector |
375 | { | 381 | { |
376 | if ( count() == 0 ) // no elements | 382 | if ( count() == 0 ) // no elements |
377 | return; | 383 | return; |
378 | register Item *start = &vec[0]; | 384 | register Item *start = &vec[0]; |
379 | register Item *end= &vec[len-1]; | 385 | register Item *end= &vec[len-1]; |
380 | Item tmp; | 386 | Item tmp; |
381 | for (;;) { // put all zero elements behind | 387 | for (;;) { // put all zero elements behind |
382 | while ( start < end && *start != 0 ) | 388 | while ( start < end && *start != 0 ) |
383 | start++; | 389 | start++; |
384 | while ( end > start && *end == 0 ) | 390 | while ( end > start && *end == 0 ) |
385 | end--; | 391 | end--; |
386 | if ( start < end ) { | 392 | if ( start < end ) { |
387 | tmp = *start; | 393 | tmp = *start; |
388 | *start = *end; | 394 | *start = *end; |
389 | *end = tmp; | 395 | *end = tmp; |
390 | } else { | 396 | } else { |
391 | break; | 397 | break; |
392 | } | 398 | } |
393 | } | 399 | } |
394 | 400 | ||
395 | #ifdef QT_THREAD_SUPPORT | 401 | #ifdef QT_THREAD_SUPPORT |
396 | QMutexLocker locker( qt_global_mutexpool->get( &sort_vec ) ); | 402 | QMutexLocker locker( qt_global_mutexpool ? |
403 | qt_global_mutexpool->get( &sort_vec ) : 0 ); | ||
397 | #endif // QT_THREAD_SUPPORT | 404 | #endif // QT_THREAD_SUPPORT |
398 | 405 | ||
399 | sort_vec = (QGVector*)this; | 406 | sort_vec = (QGVector*)this; |
400 | qsort( vec, count(), sizeof(Item), cmp_vec ); | 407 | qsort( vec, count(), sizeof(Item), cmp_vec ); |
401 | sort_vec = 0; | 408 | sort_vec = 0; |
402 | } | 409 | } |
403 | 410 | ||
404 | int QGVector::bsearch( Item d ) const // binary search; when sorted | 411 | int QGVector::bsearch( Item d ) const // binary search; when sorted |
405 | { | 412 | { |
406 | if ( !len ) | 413 | if ( !len ) |
407 | return -1; | 414 | return -1; |
408 | if ( !d ) { | 415 | if ( !d ) { |
409 | #if defined(QT_CHECK_NULL) | 416 | #if defined(QT_CHECK_NULL) |
410 | qWarning( "QGVector::bsearch: Cannot search for null object" ); | 417 | qWarning( "QGVector::bsearch: Cannot search for null object" ); |
411 | #endif | 418 | #endif |
412 | return -1; | 419 | return -1; |
413 | } | 420 | } |
414 | int n1 = 0; | 421 | int n1 = 0; |
415 | int n2 = len - 1; | 422 | int n2 = len - 1; |
416 | int mid = 0; | 423 | int mid = 0; |
417 | bool found = FALSE; | 424 | bool found = FALSE; |
418 | while ( n1 <= n2 ) { | 425 | while ( n1 <= n2 ) { |
419 | int res; | 426 | int res; |
420 | mid = (n1 + n2)/2; | 427 | mid = (n1 + n2)/2; |
421 | if ( vec[mid] == 0 ) // null item greater | 428 | if ( vec[mid] == 0 ) // null item greater |
422 | res = -1; | 429 | res = -1; |
423 | else | 430 | else |
424 | res = ((QGVector*)this)->compareItems( d, vec[mid] ); | 431 | res = ((QGVector*)this)->compareItems( d, vec[mid] ); |
425 | if ( res < 0 ) | 432 | if ( res < 0 ) |
426 | n2 = mid - 1; | 433 | n2 = mid - 1; |
427 | else if ( res > 0 ) | 434 | else if ( res > 0 ) |
428 | n1 = mid + 1; | 435 | n1 = mid + 1; |