36 #ifdef ENABLE_VECTORDEBUG
37 #define VECTORDEBUG(...) { printf(__VA_ARGS__); printf(" this=%p [%p,%p,%p]\n",(void*)this,(void*)&mData,mStart,mEnd); }
40 #define VECTORDEBUG(...)
43 #define BITVECTOR_REFCNTS 0
47 template <
class T>
class RCData :
public RefCntBase {
127 #if BITVECTOR_REFCNTS
139 mData = elements ?
new T[elements] : NULL;
148 VECTORDEBUG(
"VectorBase::shiftMem(%p)",(
void*)&other);
164 this->
mEnd=
const_cast<T*
>(other.
mEnd);
183 VECTORDEBUG(
"VectorBase::resize(%p,%d) %s",
this,newElements, (
mData?
"delete":
""));
227 snprintf(buf,100,
" mData=%p mStart=%p mEnd=%p ",(
void*)
mData,
mStart,
mEnd);
228 return std::string(buf);
240 T* base = other.
mStart + start;
241 assert(base+span<=other.
mEnd);
243 memcpy(base,
mStart,span*
sizeof(T));
260 const T* base =
mStart + start;
261 assert(base+span<=
mEnd);
263 memcpy(other.
mStart,base,span*
sizeof(T));
269 while (dp<
mEnd) *dp++=val;
272 void fill(
const T& val,
unsigned start,
unsigned length)
277 while (dp<end) *dp++=val;
310 #if BITVECTOR_REFCNTS
311 const T*
getData()
const {
return this->
mData.isNULL() ? 0 : this->
mData->mPointer; }
339 assert(this->
mData == 0);
354 T* wStart = this->
mStart + start;
355 T* wEnd = wStart + span;
356 assert(wEnd<=this->
mEnd);
363 T* wStart = this->
mStart + start;
364 T* wEnd = wStart + span;
365 assert(wEnd<=this->
mEnd);
389 std::ostream& operator<<(std::ostream& os, const Vector<T>& v)
391 for (
unsigned i=0; i<v.size(); i++) os << v[i] <<
" ";
void makeAlias(const VectorBase< T > &other)
Definition: Vector.h:157
void operator=(const VectorBase< T > &other)
Definition: Vector.h:283
T * mStart
start of useful data
Definition: Vector.h:133
void vInit(size_t elements)
Definition: Vector.h:137
void operator=(Vector< T > &other)
Definition: Vector.h:346
std::string inspect() const
Definition: Vector.h:225
void vConcat(const VectorBase< T > &other1, const VectorBase< T > &other2)
Definition: Vector.h:198
void copyToSegment(VectorBase< T > &other, size_t start=0) const
Definition: Vector.h:247
const Vector< T > head(size_t span) const
Definition: Vector.h:370
void fill(const T &val)
Definition: Vector.h:266
size_t size() const
Definition: Vector.h:170
void resize(size_t newElements)
Definition: Vector.h:181
T * VectorDataType
Definition: Vector.h:130
VectorBase()
Definition: Vector.h:206
VectorDataType mData
allocated data block.
Definition: Vector.h:132
void fill(const T &val, unsigned start, unsigned length)
Definition: Vector.h:272
size_t bytes() const
Definition: Vector.h:178
const T * begin() const
Definition: Vector.h:306
void segmentCopyTo(VectorBase< T > &other, size_t start, size_t span) const
Definition: Vector.h:258
Vector(const Vector< T > &other)
Definition: Vector.h:329
Vector(const Vector< T > &other1, const Vector< T > &other2)
Definition: Vector.h:338
const T & operator[](size_t index) const
Definition: Vector.h:300
T * mEnd
end of useful data + 1
Definition: Vector.h:134
void copyToSegment(VectorBase< T > &other, size_t start, size_t span) const
Definition: Vector.h:238
#define VECTORDEBUG(...)
Definition: Vector.h:40
void shiftMem(VectorBase< T > &other)
Definition: Vector.h:146
Vector< T > head(size_t span)
Definition: Vector.h:369
void copyTo(VectorBase< T > &other) const
Definition: Vector.h:249
Vector(size_t wSize=0)
Definition: Vector.h:323
Vector(T *wData, T *wStart, T *wEnd)
Definition: Vector.h:332
bool isOwner()
Definition: Vector.h:223
Vector< T > segment(size_t start, size_t span)
Definition: Vector.h:352
T * end()
Definition: Vector.h:309
void clear()
Definition: Vector.h:189
void operator=(const Vector< T > &other)
Definition: Vector.h:349
void clone(const VectorBase< T > &other)
Definition: Vector.h:193
Vector(Vector< T > &other)
Definition: Vector.h:326
T & operator[](size_t index)
Definition: Vector.h:294
Vector< T > tail(size_t start)
Definition: Vector.h:371
T * iterator
Definition: Vector.h:376
const Vector< T > tail(size_t start) const
Definition: Vector.h:372
const T * const_iterator
Definition: Vector.h:377
T * begin()
Definition: Vector.h:307
Vector(T *wStart, size_t span)
Definition: Vector.h:335
const T * end() const
Definition: Vector.h:308
const Vector< T > segment(size_t start, size_t span) const
Definition: Vector.h:361
~VectorBase()
Definition: Vector.h:217
const T * getData() const
Definition: Vector.h:313
VectorBase(VectorDataType wData, T *wStart, T *wEnd)
Definition: Vector.h:209