43 #define USE_MALLOC // comment to use new/delete 48 #if defined(USE_MALLOC) 49 #define NEW(type,size) ((type*)malloc(size*sizeof(type))) 50 #define DELETE(array) (free((char*)array)) 52 #define NEW(type,size) (new type[size]) 53 #define DELETE(array) (delete[] array) 54 #define DONT_USE_REALLOC // comment to use realloc() 115 #if defined(CHECK_RANGE) 116 qWarning(
"QGArray: Cannot allocate array with negative length" );
211 if ( newsize ==
shd->
len )
213 if ( newsize == 0 ) {
218 #if defined(DONT_USE_REALLOC) 219 char *newdata =
NEW(
char,newsize);
253 else if ( !
resize( len*sz ) )
256 memset(
data(), *d, len );
257 else if ( sz == 4 ) {
262 }
else if ( sz == 2 ) {
268 register char *
x =
data();
378 if ( d == 0 || len == 0 ) {
386 data =
NEW(
char,len);
388 memcpy( data, d, len );
502 #if defined(CHECK_STATE) 503 qWarning(
"QGArray::resetRawData: Inconsistent arguments" );
525 if ( index >=
shd->
len ) {
526 #if defined(CHECK_RANGE) 527 qWarning(
"QGArray::find: Index %d out of range", index/sz );
537 for ( i=index; i<
shd->
len; i++ ) {
547 for ( i=index; i<
shd->
len; i+=2 ) {
557 for ( i=index; i<
shd->
len; i+=4 ) {
565 for ( i=index; i<
shd->
len; i+=sz ) {
566 if ( memcmp( d, &
shd->
data[i], sz ) == 0 )
590 register char *
x =
data();
619 for ( i=0; i<
shd->
len; i+=sz ) {
620 if ( memcmp(d, &
shd->
data[i], sz) == 0 )
631 #if defined(Q_C_CALLBACKS) 635 static int cmp_arr(
const void *n1,
const void *n2 )
638 : (
int)((intptr_t)n1 - (intptr_t)n2);
642 #if defined(Q_C_CALLBACKS) 654 int numItems =
size() / sz;
669 int numItems =
size() / sz;
678 return (
int)(( r -
shd->
data ) / sz);
703 if ( index >=
shd->
len ) {
704 if ( !
resize( index+sz ) )
707 memcpy(
data() + index, d, sz );
719 #if defined(CHECK_RANGE) 720 qWarning(
"QGArray::at: Absolute index %d out of range", index );
static void msg_index(uint)
void resetRawData(const char *d, uint len)
bool setExpand(uint index, const char *d, uint sz)
void qWarning(const char *msg,...)
int find(const char *d, uint index, uint sz) const
virtual void deleteData(array_data *p)
virtual array_data * newData()
QGArray & setRawData(const char *d, uint len)
The QGArray class is an internal class for implementing the QArray class.
int contains(const char *d, uint sz) const
static int cmp_arr(const void *n1, const void *n2)
bool resize(uint newsize)
QGArray & duplicate(const QGArray &a)
void store(const char *d, uint len)
QGArray & assign(const QGArray &a)
bool fill(const char *d, int len, uint sz)
bool isEqual(const QGArray &a) const
int bsearch(const char *d, uint sz) const