80 : ptrData(
NULL), allocator(allocator)
88 : ptrData(
NULL), allocator(allocator)
90 this->allocator->
alloc(*
this,
size, value);
96 this->allocator->
dealloc(*
this);
109 this->allocator->
resize(*
this,
src.size());
125 this->allocator->
resize(*
this,
src.size());
141 if (this->dataSize !=
rhs.dataSize)
153 if (this->allocator) {
154 if (this->allocator == allocator)
156 this->allocator->
dealloc(*
this);
157 delete this->allocator;
159 this->allocator = allocator;
160 this->allocator->
alloc(*
this, 0);
165 bool empty()
const {
return dataSize == 0; }
171 return allocator->
resize(*
this, dataSize, value);
179 std::swap(this->ptrData,
rhs.ptrData);
180 std::swap(this->dataSize,
rhs.dataSize);
181 std::swap(this->allocator,
rhs.allocator);
186#if !defined(VF_NO_RANGECHECK) && (defined(VF_DEBUG) || defined(VF_RANGECHECK))
197#if !defined(VF_NO_RANGECHECK) && (defined(VF_DEBUG) || defined(VF_RANGECHECK))
242 if (
vec.getAllocator() !=
this)
249 if (
vec.getAllocator() !=
this)
271 return this->
resize(src, dataSize, value);
value_type *& ptrDataOf(CbVector< value_type > &vec)
virtual bool alloc(CbVector< value_type > &vec, const size_type &dataSize, const value_type &value=value_type())=0
CbVectorAllocator()=default
virtual bool resize(CbVector< value_type > &vec, const size_type &dataSize, const value_type &value=value_type())=0
virtual bool dealloc(CbVector< value_type > &vec)=0
typename CbVector< T >::value_type value_type
virtual ~CbVectorAllocator()=default
typename CbVector< value_type >::size_type size_type
size_type & dataSizeOf(CbVector< value_type > &vec)
bool resize(CbVector< value_type > &vec, const size_type &dataSize, const value_type &value=value_type()) override
typename CbVector< value_type >::size_type size_type
bool dealloc(CbVector< value_type > &vec) override
typename CbVector< T >::value_type value_type
bool alloc(CbVector< value_type > &src, const size_type &dataSize, const value_type &value=value_type()) override
A class implements a container like a vector.
CbVector & operator=(const std::vector< value_type > &src)
void setAllocator(CbVectorAllocator< value_type > *const &allocator)
value_type & operator[](const size_type &i)
CbVectorAllocator< value_type > * getAllocator() const
const value_type & operator[](const size_type &i) const
CbVector(const CbVector< value_type > &src)=delete
CbVector(const size_type size, CbVectorAllocator< value_type > *const &allocator=new CbVectorAllocatorStd< value_type >, const value_type &value=value_type())
CbVector & operator=(const CbVector &src)
CbVector(CbVectorAllocator< value_type > *const &allocator=new CbVectorAllocatorStd< value_type >)
bool resize(const size_type &dataSize)
bool resize(const size_type &dataSize, const value_type &value)
bool operator==(const CbVector &rhs) const
std::shared_ptr< T > SPtr
bool isUbEqual(const T1 &a, const T2 &b)
std::string toString(const T &x, int precision=15)