66 memcpy(
items_ + offset,
data,
sizeof(T)*len );
89 for(
int i=0; i<len; ++i ) {
items_ [offset + i] =
data; }
109 int currentLength=this->length();
110 Q_ASSERT( 0 <= offset && ((offset+
length) <= currentLength) );
111 Q_UNUSED(currentLength);
122 if(
length == newLength ) {
126 }
else if(
length < newLength ) {
127 int gapSizeRequired = newLength -
length;
130 memcpy(
items_ + offset,
data,
sizeof(T) * newLength );
136 memcpy(
items_ + offset,
data,
sizeof(T) * newLength );
142 Q_ASSERT( this->gapSize() <=
capacity_ );
152 int currentLength=this->length();
153 Q_ASSERT( 0 <= offset && ((offset+
length) <= currentLength) );
154 Q_UNUSED(currentLength);
161 if(
length == newLength ) {
165 }
else if(
length < newLength ) {
166 int gapSizeRequired = newLength -
length;
169 for(
int i=0; i<newLength; ++i ) {
items_[offset+i] =
data; }
175 for(
int i=0; i<newLength; ++i ) {
items_[offset+i] =
data; }
181 Q_ASSERT( this->gapSize() <=
capacity_ );
198 T
at(
int offset )
const {
199 Q_ASSERT( 0 <= offset && offset <
length() );
198 T
at(
int offset )
const {
…}
208 void set(
int offset,
const T& value ) {
209 Q_ASSERT( 0 <= offset && offset <
length() );
208 void set(
int offset,
const T& value ) {
…}
220 Q_ASSERT( 0 <= offset && offset <
length() );
242 Q_ASSERT( 0 <= offset && offset < this->
length() );
243 Q_ASSERT( (offset+
length) <= this->length() );
249 memcpy(
data,
items_ + offset,
sizeof(T)*len );
278 Q_ASSERT( offset <=
length() );
298#ifdef GAP_VECTOR_CLEAR_GAP
306 if(
gapSize() < requiredSize ) {
326 T *newChars =
new T[ newSize ];
329 memmove( newChars,
items_,
sizeof(T)*lengte );
337#ifdef GAP_VECTOR_CLEAR_GAP
356 int gapEnd = this->gapEnd();
360 if(
items_[i].isNull() ) {
372 if(
items_[i].isNull() ) {
386 int gapEnd = this->gapEnd();
390 if( i ) { s.append(
","); }
391 if(
gapEnd == i) s.append(
">");
392 s.append( QStringLiteral(
"%1").arg(
"X" ));
508 for(
int i=0; i < newLength; i++ ) {
509 items_.insert(offset+i,data[i]);
517 void fill(
int offset,
int length,
const T& data,
int newLength ) {
519 for(
int i=0; i < newLength; i++ ) {
520 items_.insert(offset+i,data);
517 void fill(
int offset,
int length,
const T& data,
int newLength ) {
…}
532 for(
int i=0; i <
length; i++ ) {
539 T
at(
int offset )
const {
539 T
at(
int offset )
const {
…}
544 void set(
int offset,
const T& value ) {
545 items_.replace(offset,value);
544 void set(
int offset,
const T& value ) {
…}
556 void copyRange( QChar* data, int offset, int length ) const {
559//qlog_info() << "copyRange" << offset << length;
560 if( !length ) { return; }
561 Q_ASSERT( 0 <= offset && offset < this->length() );
562 Q_ASSERT( (offset+length) <= this->length() );
564 // copy the first part
565 if( offset < gapBegin() ) {
566 int len = qMin( gapBegin_-offset, length );
567//qlog_info() << " - 1: memcpy: offset=" << offset << ", len=" << len << items_[offset];
568 memcpy( data, items_ + offset, sizeof(T)*len );
569 data += len; // increase the pointer
575//qlog_info() << " - 2: memcpy: offset="<<offset << "gapSize=" << gapSize()<< ", length=" << length << items_[offset + gapSize()];
576 memcpy( data, items_ + offset + gapSize(), sizeof(T)*length );
622 void ensureGapSize( int requiredSize ) {
623 if( gapSize() < requiredSize ) {
624 while( growSize_ < capacity_ / 6) { growSize_ *= 2; }
625 resize(capacity_ + requiredSize + growSize_ - gapSize() );
631 void resize(int newSize)
633 if( capacity_ >= newSize) return;
634 int lengte = length();
635 Q_ASSERT( lengte <= capacity_);
639//qlog_info() << "BEGIN resize: capacity =" << capacity_<< " => " << newSize;
643 T *newChars = new T[ newSize ];
645 if( capacity_ > 0 ) {
646 memmove( newChars, items_, sizeof(T)*lengte );
652//qlog_info() << "END resize";
657 void setGrowSize( int size ) { growSize_=size; }
660 int growSize() { return growSize_; }
664 QString getUnitTestString( QChar gapChar = '_' ) const {
666 int gapBegin = this->gapBegin();
667 int gapEnd = this->gapEnd();
668 int capacity = this->capacity();
670 for( int i=0; i<gapBegin; ++i ) {
671 if( items_[i].isNull() ) {
674 s.append( items_[i] );
678 for( int i=gapBegin; i<gapEnd; ++i ) {
682 for( int i=gapEnd; i<capacity; ++i ) {
683 if( items_[i].isNull() ) {
686 s.append( items_[i] );
void set(int offset, const T &value)
This method sets an item at the given index.
Definition gapvector.h:208
void copyRange(QChar *data, int offset, int length) const
This method copies the given range to the data pointer.
Definition gapvector.h:237
void resize(int newSize)
resizes the array of data
Definition gapvector.h:314
void ensureGapSize(int requiredSize)
this method makes sure there's enough room for the insertation
Definition gapvector.h:305
int gapEnd() const
Definition gapvector.h:37
int growSize_
The size to grow extra.
Definition gapvector.h:405
void append(T t)
convenient append method
Definition gapvector.h:187
void append(const T *t, int length)
another append method
Definition gapvector.h:192
T * data()
This method returns a direct pointer to the 0-terminated buffer This pointer is only valid as long as...
Definition gapvector.h:265
void replace(int offset, int length, const T *data)
this method replaces the given text with the given data. because the length of the source and target ...
Definition gapvector.h:60
T at(int offset) const
This method returns the item at the given index.
Definition gapvector.h:198
int growSize()
returns the growsize
Definition gapvector.h:349
QString getUnitTestString(QChar gapChar='_') const
Converts the 'gap-buffer' to a unit-test debugging string.
Definition gapvector.h:353
int gapEnd_
The end of the gap.
Definition gapvector.h:404
int gapBegin() const
Definition gapvector.h:36
QString getUnitTestString2() const
Converts the 'gap-buffer' to a unit-test debugging string.
Definition gapvector.h:383
T * items_
The item data.
Definition gapvector.h:401
int capacity_
The number of reserved bytes.
Definition gapvector.h:402
int gapBegin_
The start of the gap.
Definition gapvector.h:403
int gapSize() const
Definition gapvector.h:35
void fill(int offset, int length, const T &data, int newLength)
this method replaces the given items with a single data item
Definition gapvector.h:151
void clear()
clears the data
Definition gapvector.h:42
int length() const
returns the used length of the data
Definition gapvector.h:34
void moveGapTo(int offset)
Definition gapvector.h:276
void replace(int offset, int length, const T *data, int newLength)
this method replaces the given items
Definition gapvector.h:108
T & rawAt(int index)
This method returns the 'raw' element at the given location This method does NOT take in account the ...
Definition gapvector.h:230
~GapVector()
Definition gapvector.h:29
T & operator[](int offset)
This method return an index.
Definition gapvector.h:219
void setGrowSize(int size)
sets the growsize. The growsize if the amount to reserve extra
Definition gapvector.h:346
int capacity() const
Definition gapvector.h:38
GapVector(int capacity=16)
Definition gapvector.h:21
void fill(int offset, int length, const T &data)
this method replaces the given text with the given data. because the length of the source and target ...
Definition gapvector.h:84
int gapBegin() const
Definition gapvector.h:485
int capacity() const
Definition gapvector.h:487
void append(T t)
convenient append method
Definition gapvector.h:526
QVector< T > items_
This method returns a direct pointer to the 0-terminated buffer This pointer is only valid as long as...
Definition gapvector.h:697
void append(const T *t, int length)
another append method
Definition gapvector.h:531
T & operator[](int offset)
This method return an index.
Definition gapvector.h:550
int length() const
returns the used length of the data
Definition gapvector.h:483
void clear()
clears the data
Definition gapvector.h:491
~NoGapVector()
Definition gapvector.h:479
NoGapVector(int capacity=16)
Definition gapvector.h:475
void set(int offset, const T &value)
This method sets an item at the given index.
Definition gapvector.h:544
T at(int offset) const
This method returns the item at the given index.
Definition gapvector.h:539
void replace(int offset, int length, const T *data, int newLength)
this method replaces the given items
Definition gapvector.h:506
int gapEnd() const
Definition gapvector.h:486
void fill(int offset, int length, const T &data, int newLength)
this method replaces the given items with a single data item
Definition gapvector.h:517
int gapSize() const
Definition gapvector.h:484
void replaceString(int offset, int length, const QString &data)
a convenient string replace function
Definition gapvector.h:438
QString mid(int offset, int length) const
a convenient method to retrieve a QString part
Definition gapvector.h:448
QCharGapVector(const QString &data, int gapSize)
initializes the vector with a given string
Definition gapvector.h:417
void init(const QString &data, int gapSize)
Initializes the gapvector.
Definition gapvector.h:426
QCharGapVector(int size=16)
Definition gapvector.h:414
#define EDBEE_EXPORT
Definition exports.h:15
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20