40 unsigned int num()
const {
return _length; }
53 unsigned int _capacity;
55 unsigned int _BLOCKSIZE;
57 std::vector<T*> _block;
59 std::vector<unsigned int> _deleted;
87 const unsigned int iBS = init/_BLOCKSIZE+1;
89 for (
unsigned int i = 0;
i <
iBS;
i++)
91 _block[
i] =
new T[_BLOCKSIZE];
93 _capacity =
iBS * _BLOCKSIZE;
108 *
this = std::move(
other);
114 _length =
other._length;
116 _capacity =
other._capacity;
118 _BLOCKSIZE =
other._BLOCKSIZE;
119 other._BLOCKSIZE = 0;
120 _block = std::move(
other._block);
121 _deleted = std::move(
other._deleted);
132 for (
size_t i=0;
i<_block.size();
i++)
134 delete [] _block[
i]; _block[
i] =
nullptr;
139 _length = _capacity = 0;
151 _capacity += _BLOCKSIZE;
161 if (!_deleted.empty())
163 *pos = _deleted.back();
165 elem = &(_block[*pos/_BLOCKSIZE][*pos%_BLOCKSIZE]);
170 static_assert(WEMInternal::has_reset_v<T>,
"Type T must implement ::reset() to reset the object back to the default constructed state.");
176 if (_length == _capacity)
181 elem = &(_block[_length/_BLOCKSIZE][_length%_BLOCKSIZE]);
193 _deleted.push_back(pos);
unsigned int num() const
Returns the number of elements in this vector.
WEMObjectVector(unsigned int init=0, unsigned int bs=8192)
Standard constructor.
WEMObjectVector & operator=(WEMObjectVector &&other) noexcept
Move assignment operator.
void destroy()
Deletes all elements in this vector.
T * append(unsigned int *pos)
Appends an element to this vector and returns a pointer to it.
~WEMObjectVector()
Standard destructor.
void deleteAt(unsigned int pos)
Deletes an element at the given position.
WEMObjectVector(WEMObjectVector &&other) noexcept
Move c'tor.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
constexpr bool has_reset_v
decltype(std::declval< T & >().reset()) object_reset_t