4template<
typename TYPE, ::i32 t_iSize, enum_array t_earray,
typename ARG_TYPE>
11 using ARRAY_RANGE = ::array_range < TYPE, ARG_TYPE >;
12 using BASE_RANGE = ::array_range < TYPE, ARG_TYPE >;
13 using RAW_BASE_ARRAY = block_array;
14 using BASE_RAW_RANGE = ::range < TYPE * >;
15 using BASE_TYPE = TYPE;
20 block_array() : ARRAY_RANGE (m_ta, m_ta){}
23 TYPE *data() {
return m_ta; }
24 const TYPE *data()
const {
return m_ta; }
26 ::collection::count storage_size()
const {
return t_iSize; }
29 template<po
inter_not_castable_to<TYPE *> P>
30 ::collection::count allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw, P &p)
33 return _allocate(nNewSize, bShrink, bRaw, &t);
35 template<po
inter_castable_to<TYPE *> T>
36 ::collection::count allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw, T &t)
38 return _allocate(nNewSize, bShrink, bRaw, &t);
44 if (this->size() >= this->storage_size())
47 throw ::exception(error_wrong_state);
51 auto & t = m_ta[this->size()];
60 ::collection::index add(
const TYPE & t)
63 if (this->size() >= this->storage_size())
66 throw ::exception(error_wrong_state);
70 auto i = this->size();
81 block_array &operator+=(
const TYPE &t)
92 constexpr bool is_raw_array()
const {
return t_earray & e_array_raw; }
97 void erase_at(::collection::index iErase, ::collection::count countErase = 1)
103 throw ::exception(error_bad_argument);
106 else if (iErase >= this->size())
109 throw ::exception(error_wrong_state);
113 if (iErase + countErase > this->size())
116 countErase = this->size() - iErase;
127 if constexpr (t_earray & e_array_raw)
130 auto nTransferCount = this->size() - (iErase + countErase);
132 auto i = iErase + countErase;
134 ::safe_memory_transfer2(&m_ta[i - countErase], nTransferCount, &m_ta[i], nTransferCount);
140 auto i = iErase + countErase;
142 for (; i < this->size(); i++)
145 m_ta[i - countErase] = m_ta[i];
151 for (; i < this->size(); i++)
156 new (&m_ta[i]) TYPE();
162 this->m_end -= countErase;
166 void erase_first(::collection::count count = 1) { this->
erase_at(0, count);
169 void erase_last(::collection::count count = 1)
171 this->
erase_at(this->size() - count, count);
176 ::collection::count _allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw,
const TYPE * ptype)
179 if (nNewSize >= this->storage_size())
182 throw ::exception(error_wrong_state);
186 auto nOldSize = this->size();
188 if (nNewSize > nOldSize)
191 for (
auto i = nOldSize; i < nNewSize; i++)
194 if constexpr (t_earray & e_array_raw)
197 safe_memory_copy2(this->m_begin+ i, 1, ptype, 1);
203 this->m_begin[i] = *ptype;
211 this->m_end = this->m_begin + nNewSize;
void erase_at(::collection::index iErase, ::collection::count countErase=1)
attention, it doesn't actually destruct the object it just not regard it as part of the "filled" arra...
Definition block_array.h:97