Go to the documentation of this file.
35 #ifdef ENABLE_VECTORDEBUG
36 #define VECTORDEBUG(...) { printf(__VA_ARGS__); printf(" this=%p [%p,%p,%p]\n",(void*)this,(void*)&mData,mStart,mEnd); }
39 #define VECTORDEBUG(...)
42 #define BITVECTOR_REFCNTS 0
46 template <
class T>
class RCData :
public RefCntBase {
126 #if BITVECTOR_REFCNTS
138 mData = elements ?
new T[elements] : NULL;
147 VECTORDEBUG(
"VectorBase::shiftMem(%p)",(
void*)&other);
149 this->mData=other.mData;
150 this->mStart=other.mStart;
151 this->mEnd=other.mEnd;
162 this->mStart=
const_cast<T*
>(other.
mStart);
163 this->mEnd=
const_cast<T*
>(other.
mEnd);
182 VECTORDEBUG(
"VectorBase::resize(%p,%d) %s",
this,newElements, (
mData?
"delete":
""));
199 memcpy(this->mStart, other1.
mStart, other1.
bytes());
226 snprintf(buf,100,
" mData=%p mStart=%p mEnd=%p ",(
void*)
mData,
mStart,
mEnd);
227 return std::string(buf);
239 T* base = other.
mStart + start;
240 assert(base+span<=other.
mEnd);
242 memcpy(base,
mStart,span*
sizeof(T));
259 const T* base =
mStart + start;
260 assert(base+span<=
mEnd);
262 memcpy(other.
mStart,base,span*
sizeof(T));
268 while (dp<
mEnd) *dp++=val;
271 void fill(
const T& val,
unsigned start,
unsigned length)
276 while (dp<
end) *dp++=val;
309 #if BITVECTOR_REFCNTS
310 const T*
getData()
const {
return this->mData.isNULL() ? 0 : this->mData->mPointer; }
338 assert(this->mData == 0);
353 T* wStart = this->mStart + start;
354 T* wEnd = wStart + span;
355 assert(wEnd<=this->
mEnd);
362 T* wStart = this->mStart + start;
363 T* wEnd = wStart + span;
364 assert(wEnd<=this->
mEnd);
390 for (
unsigned i=0; i<v.
size(); i++) os << v[i] <<
" ";
const T & operator[](size_t index) const
Definition: Vector.h:299
Vector< T > head(size_t span)
Definition: Vector.h:368
void clear()
Definition: Vector.h:188
void operator=(const Vector< T > &other)
Definition: Vector.h:348
Vector(size_t wSize=0)
Definition: Vector.h:322
void clone(const VectorBase< T > &other)
Definition: Vector.h:192
Vector< T > tail(size_t start)
Definition: Vector.h:370
T * mEnd
end of useful data + 1
Definition: Vector.h:133
std::ostream & operator<<(std::ostream &os, const Vector< T > &v)
Definition: Vector.h:388
T & operator[](size_t index)
Definition: Vector.h:293
bool isOwner()
Definition: Vector.h:222
void copyToSegment(VectorBase< T > &other, size_t start=0) const
Definition: Vector.h:246
T * iterator
Definition: Vector.h:375
const T * const_iterator
Definition: Vector.h:376
size_t bytes() const
Definition: Vector.h:177
T * begin()
Definition: Vector.h:306
void operator=(const VectorBase< T > &other)
Definition: Vector.h:282
const Vector< T > tail(size_t start) const
Definition: Vector.h:371
Vector(T *wStart, size_t span)
Definition: Vector.h:334
VectorBase(VectorDataType wData, T *wStart, T *wEnd)
Definition: Vector.h:208
void makeAlias(const VectorBase< T > &other)
Definition: Vector.h:156
void copyToSegment(VectorBase< T > &other, size_t start, size_t span) const
Definition: Vector.h:237
Vector(T *wData, T *wStart, T *wEnd)
Definition: Vector.h:331
Vector(const Vector< T > &other)
Definition: Vector.h:328
~VectorBase()
Definition: Vector.h:216
Vector(const Vector< T > &other1, const Vector< T > &other2)
Definition: Vector.h:337
void vInit(size_t elements)
Definition: Vector.h:136
size_t size() const
Definition: Vector.h:169
T * mStart
start of useful data
Definition: Vector.h:132
const T * getData() const
Definition: Vector.h:312
void resize(size_t newElements)
Definition: Vector.h:180
T * VectorDataType
Definition: Vector.h:129
VectorBase()
Definition: Vector.h:205
void operator=(Vector< T > &other)
Definition: Vector.h:345
void vConcat(const VectorBase< T > &other1, const VectorBase< T > &other2)
Definition: Vector.h:197
void segmentCopyTo(VectorBase< T > &other, size_t start, size_t span) const
Definition: Vector.h:257
VectorDataType mData
allocated data block.
Definition: Vector.h:131
Vector(Vector< T > &other)
Definition: Vector.h:325
const Vector< T > segment(size_t start, size_t span) const
Definition: Vector.h:360
const Vector< T > head(size_t span) const
Definition: Vector.h:369
void fill(const T &val, unsigned start, unsigned length)
Definition: Vector.h:271
void fill(const T &val)
Definition: Vector.h:265
const T * begin() const
Definition: Vector.h:305
#define VECTORDEBUG(...)
Definition: Vector.h:39
void copyTo(VectorBase< T > &other) const
Definition: Vector.h:248
T * end()
Definition: Vector.h:308
void shiftMem(VectorBase< T > &other)
Definition: Vector.h:145
Vector< T > segment(size_t start, size_t span)
Definition: Vector.h:351
const T * end() const
Definition: Vector.h:307
std::string inspect() const
Definition: Vector.h:224