5#include "acme/memory/typed.h"
6#include "acme/memory/typed_memory.h"
7#include "acme/memory/operation.h"
8#include "acme/prototype/prototype/particle.h"
11template <
typename TYPE >
12const TYPE * find_first_non_null(
const TYPE * p)
22CLASS_DECL_ACME ::string get_task_object_name();
26CLASS_DECL_ACME ::string get_task_object_debug();
31#define __default_array_base_array_non_particle(TYPE) ::base_array < TYPE, const TYPE &, ::allocator::def < TYPE > >
34#define DECLARE_TYPED_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE, CONTAINER_TYPE) \
35::pointer<TYPE>& ITEM ## _at(::collection::index i) { return CONTAINER[i]; } \
36const TYPE * ITEM ## _at(::collection::index i) const { return CONTAINER[i]; } \
37::pointer<TYPE>* ITEM ## _data() { return CONTAINER.data(); } \
38::pointer<TYPE>const * ITEM ## _data() const { return CONTAINER.data(); } \
39TYPE * get_ ## ITEM(::collection::index i) const { return CONTAINER.bounds(i) ? CONTAINER[i] : nullptr; } \
40::collection::count ITEM ## _count() const { return CONTAINER.get_count(); } \
41bool has_ ## ITEM() const { return CONTAINER.has_element(); } \
42const CONTAINER_TYPE & ITEM ## a() const { return CONTAINER; } \
43CONTAINER_TYPE & ITEM ## a() { return CONTAINER; } \
44bool contains_ ## ITEM(const TYPE * p) const { return CONTAINER.contains(p); } \
45bool is_there_no_ ## ITEM() const { return CONTAINER.is_empty(); } \
46bool has_no_ ## ITEM() const { return is_there_no_ ## ITEM(); } \
47::collection::index find_first_ ## ITEM(const TYPE * p, ::collection::index iStart = 0, ::collection::count nCount = -1) const { return CONTAINER.find_first(p, iStart, nCount); } \
48::pointer<TYPE>& first_ ## ITEM() { return CONTAINER.first_pointer(); } \
49::pointer<TYPE>& last_ ## ITEM() { return CONTAINER.last_pointer(); } \
50TYPE * get_first_ ## ITEM() const { return CONTAINER.get_first_pointer(); } \
51TYPE * get_last_ ## ITEM() const { return CONTAINER.get_last_pointer(); } \
52::collection::index ITEM ## _first_index(::collection::index i = 0) const { return CONTAINER.first_index(i); } \
53::collection::index ITEM ## _last_index(::collection::index i = -1) const { return CONTAINER.last_index(i); } \
54CONTAINER_TYPE CONTAINER
56#define DECLARE_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE) \
57DECLARE_TYPED_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE, pointer_array_base < TYPE >)
59#define DECLARE_TYPED_ARRAY_OF(ITEM, CONTAINER, TYPE, CONTAINER_TYPE) \
60::collection::index add_ ## ITEM(TYPE * p) { return CONTAINER.add_item(p); } \
61::collection::index add_ ## ITEM ## _array(const CONTAINER_TYPE & a) { return CONTAINER.append(a); } \
62::collection::index add_unique_ ## ITEM(TYPE * p) { return CONTAINER.add_unique(p); } \
63::collection::index add_unique_ ## ITEM ## _array(const CONTAINER_TYPE & a) { return CONTAINER.add_unique(a); } \
64::collection::index erase_ ## ITEM(TYPE * p) { return CONTAINER.erase(p); } \
65CONTAINER_TYPE ITEM ## a_section(::collection::index iStart = 0, ::collection::count nCount = -1){return CONTAINER.slice < CONTAINER_TYPE >(iStart, nCount);} \
66template < typename ARRAY > \
67void ITEM ## a_slice(ARRAY & a, ::collection::index iStart = 0, ::collection::count nCount = -1){ CONTAINER.slice(a, iStart, nCount);} \
68DECLARE_TYPED_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE, CONTAINER_TYPE)
70#define HAVE_ARRAY_OF(ITEM, CONTAINER, TYPE) \
71DECLARE_TYPED_ARRAY_OF(ITEM, CONTAINER, TYPE, pointer_array_base < TYPE >)
73#define DECLARE_ARRAY_CONTAINER_OF(ARRAY, ITEM, CONTAINER, TYPE) \
74ARRAY(const ::std::initializer_list < ::pointer<TYPE >>& list_base) : CONTAINER(list_base) { } \
75DECLARE_TYPED_ARRAY_OF(ITEM, CONTAINER, TYPE, pointer_array_base < TYPE >)
77#define DECLARE_ARRAY_OF(ARRAY, ITEM, TYPE) \
78DECLARE_ARRAY_CONTAINER_OF(ARRAY, ITEM, m_ ## ITEM ## a, TYPE)
81#include "acme/prototype/collection/rear_iterator.h"
86template <
typename A,
typename B >
87auto distance(
const pointer_rear_iterator < A > & a,
const pointer_rear_iterator < B > & b) {
return (a < b) ? (b - a) : (a - b); }
88template <
typename A,
typename B >
89auto distance(
const A * pa,
const B * pb) {
return (pa < pb) ? (pb - pa) : (pa - pb); }
107template <
class TYPE,
class ARG_TYPE,
class TYPED,
class MEMORY, ::enum_type t_etypeContainer >
116 using THIS_ARRAY = base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >;
117 using RAW_BASE_ARRAY = THIS_ARRAY;
123 using ARRAY_RANGE = ::array_range < TYPE, ARG_TYPE >;
124 using BASE_RAW_RANGE = ::range < TYPE * >;
129 using CONTAINER_ITEM_TYPE = TYPE;
130 using TYPE_IS_PTR = TYPE;
132 using this_iterator =
typename ARRAY_RANGE::this_iterator;
133 using iterator =
typename ARRAY_RANGE::iterator;
134 using const_iterator =
typename ARRAY_RANGE::const_iterator;
138 ::collection::count m_countAllocation;
139 ::collection::count m_countAddUp;
140 ::collection::count m_countAllocationOffset;
148 base_array(nullptr_t) : base_array() {}
157 base_array(const ::enum_range & erange, ::collection::count c);
164 base_array(
const std::initializer_list < TYPE > & initializer_list);
165 base_array(
const base_array< TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & array);
166 base_array(base_array< TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > && array)
noexcept;
172 base_array(::collection::count c) : base_array() { this->set_size(c); }
173 template <
typename OTHER_TYPE >
174 base_array(::collection::count c,
const OTHER_TYPE * p)
175 requires (::std::is_convertible_v < OTHER_TYPE, CONTAINER_ITEM_TYPE >);
193 template <
typename OTHER_RANGE >
194 base_array(
const OTHER_RANGE & range)
requires
195 (container_range < OTHER_RANGE >
196 && !::std::is_base_of_v < base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >, ::std::remove_cvref_t < OTHER_RANGE > >);
200 template < prototype_
integral INTEGRAL >
201 base_array(const_iterator begin, INTEGRAL count) : base_array(begin, begin + count) {}
202 base_array(const_iterator begin, const_iterator end)
204 auto p = this->begin();
205 while (p != end) add(*p);
207 template <
typename SOME_TYPE >
208 base_array(
null_terminated_t,
const SOME_TYPE *begin) : base_array(begin, find_first_non_null(begin))
214 void array_base_ok()
const;
216 void container_ok()
const
225 void defer_erase_allocation_offset();
230 if (this->m_begin !=
nullptr)
240 base_array & operator += (
const TYPE & t)
250 base_array & operator += (
const base_array & a)
256 auto i = this->size();
264 auto ptarget = this->data() + i;
266 auto psource = a.data();
288 base_array & operator += (base_array && base_array)
291 if (
this != &base_array)
294 auto i = this->size();
296 auto add = base_array.size();
298 transfer(i, add, ::transfer(base_array));
307 template < prototype_array ARRAY >
308 base_array & operator += (
const ARRAY & a)
311 auto i = this->size();
323 for (; i < c; i++, p++)
326 this->element_at(i) = *p;
335 base_array & operator += (
const std::initializer_list < TYPE > & initializer_list)
338 for (
auto &
item : initializer_list)
350 base_array & operator = (
const base_array & a)
360 auto ptarget = this->data();
362 auto psource = a.data();
364 TYPED::copy_count(ptarget, psource, c);
373 base_array & operator = (base_array && base_array)
376 if (
this != &base_array)
379 transfer(::transfer(base_array));
388 template < prototype_container CONTAINER >
389 base_array & assign_a_container(
const CONTAINER & container)
392 this->set_size(container.size());
394 auto p = container.begin();
396 ::collection::index i = 0;
398 while (!container.is_end(p))
401 this->element_at(i) = *p;
414 template < prototype_container CONTAINER >
415 base_array & copy(
const CONTAINER & container)
418 this->set_size(container.size());
420 auto p = container.begin();
422 ::collection::index i = 0;
424 while (!container.is_end(p))
427 ::copy(&this->element_at(i), &(*p));
440 template < std_range STDRANGE >
441 base_array & assign_a_std_range (
const STDRANGE & range)
446 for (
auto &
item : range)
458 template < prototype_container CONTAINER >
459 base_array & operator = (
const CONTAINER & container)
460 requires (!::std::is_base_of<base_array, CONTAINER >::value)
463 return this->assign_a_container(container);
468 template < std_range STDRANGE >
469 base_array & operator = (
const STDRANGE & range)
470 requires (!::std::is_base_of<base_array, STDRANGE >::value
474 return this->assign_a_std_range(range);
479 base_array & operator = (
const std::initializer_list<TYPE> & initializerlist)
482 return this->assign_a_std_range(initializerlist);
487 template<
typename... Args>
488 TYPE& add_construct(Args&&... args)
490 return this->add(TYPE(std::forward<Args>(args)...));
492 TYPE& add_construct()
494 return this->add(TYPE());
501 memset(&t, 0,
sizeof(TYPE));
507 void add_initializer_list(const ::std::initializer_list < TYPE > & initializer_list)
510 for (
auto &
item : initializer_list)
520 inline base_array & transfer(base_array && a)
528 ARRAY_RANGE::operator=(::transfer(a));
530 m_countAddUp = a.m_countAddUp;
532 m_countAllocation = a.m_countAllocation;
541 inline base_array & transfer(::collection::index i, ::collection::count add, base_array && a, collection::index j = 0)
551 for (; i < c; i++, j++)
554 this->element_at(i) = a[j];
565 inline ::range<rear_iterator> rear_payloads()
568 return ::range<rear_iterator>(this->rear_begin(), this->rear_end());
573 inline ::range<const_rear_iterator> rear_payloads()
const
576 return ::range<const_rear_iterator>(this->rear_begin(), this->rear_end());
581 ::block as_block()
const
584 return { (
const void*)this->data(), this->get_size_in_bytes() };
893 inline memsize length_in_bytes()
const {
return this->size() *
sizeof(TYPE); }
923 inline bool contains_address(
const TYPE * pmatter)
const {
return pmatter >= this->m_begin && pmatter < this->end(); }
926 inline ::collection::count get_size()
const;
927 inline ::collection::count get_size_in_bytes()
const;
928 inline ::collection::count get_count()
const;
929 inline ::collection::count get_byte_count()
const;
930 inline ::collection::count get_length()
const;
932 inline ::collection::count count()
const;
933 inline ::collection::count length()
const;
934 inline ::collection::count byte_count()
const {
return get_byte_count(); }
937 inline bool has_element()
const noexcept {
return this->size() > 0; }
938 inline bool is_empty(::collection::count countMinimum = 0)
const noexcept {
return this->size() <= countMinimum; }
939 inline bool empty(::collection::count countMinimum = 0)
const noexcept {
return this->size() <= countMinimum; }
940 inline bool has_elements(::collection::count countMinimum = 1)
const noexcept {
return this->size() >= countMinimum; }
943 inline this_iterator back(::collection::index i = -1) {
return (this_iterator)(this->begin() + this->get_upper_bound(i)); }
944 inline const_iterator back(::collection::index i = -1)
const {
return (const_iterator)(this->begin() + this->get_upper_bound(i)); }
946 void ensure_index_ok(::collection::index nIndex)
const {
if (nIndex < 0 || nIndex >= this->size()) throw_exception(error_index_out_of_bounds); }
949 inline const TYPE& at(::collection::index nIndex)
const { ensure_index_ok(nIndex);
return this->element_at(nIndex); }
950 inline TYPE& at(::collection::index nIndex) { ensure_index_ok(nIndex);
return this->element_at(nIndex); }
952 inline void set_at_grow(::collection::index nIndex, ARG_TYPE newElement);
953 inline TYPE & element_at_grow(::collection::index nIndex);
954 inline TYPE & atø(::collection::index nIndex) {
return this->element_at_grow(nIndex); }
956 inline void set_each(ARG_TYPE element, ::collection::index iStart = 0, ::collection::count c = -1);
958 template < ::std::
size_t N >
959 TYPE & get() {
return this->element_at(N); }
962 void reserve(::collection::count newAllocationSize);
965 ::collection::count set_size(::collection::count nNewSize);
971 template < po
inter_not_castable_to < TYPE * > P >
972 ::collection::count
allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw, P & p)
975 return _allocate(nNewSize, bShrink, bRaw,
false, &t);
977 template < po
inter_castable_to < TYPE * > T >
978 ::collection::count
allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw, T & t)
980 return _allocate(nNewSize, bShrink, bRaw,
false, &t);
982 ::collection::count
allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw)
984 return _allocate(nNewSize, bShrink, bRaw,
false,
nullptr);
986 ::collection::count _allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw,
bool bFollowingIsArray,
const TYPE * type);
990 ::collection::count allocate_in_bytes(::collection::count nNewSize,
bool bShrink,
bool bRaw);
994 ::collection::count resize(::collection::count nNewSize) {
return set_size(nNewSize); }
995 ::collection::count resize(::collection::count nNewSize, ARG_TYPE t);
1000 inline void __swap(::collection::index index1, ::collection::index index2);
1001 inline void __swap(iterator index1, iterator index2);
1002 inline void __swap(const_iterator index1, const_iterator index2);
1005 void set_all(
const TYPE & t);
1008 rear_iterator rear_begin()
1010 return this->m_end - 1;
1013 rear_iterator rear_end()
1015 return this->m_begin - 1;
1018 const_rear_iterator rear_begin()
const
1020 return (const_rear_iterator&)this->m_end - 1;
1023 const_rear_iterator rear_end()
const
1025 return (const_rear_iterator&)this->m_begin - 1;
1029 void zero(::collection::index iStart = 0, ::collection::count c = -1);
1034 template < prototype_array ARRAY >
1035 void erase_indexes(
const ARRAY & ia);
1037 template < prototype_array ARRAY >
1038 void erase_descending_indexes(
const ARRAY & ia);
1043 inline void erase_first(::collection::count c = 1);
1044 inline void erase_last(::collection::count c = 1);
1045 inline ::collection::count erase_all();
1046 inline void clear();
1049 void on_construct_element(TYPE * p) { TYPED::construct(p); }
1050 void on_construct_element(TYPE * p, ::collection::count c) { TYPED::construct_count(p, c); }
1051 void on_destruct_element(TYPE * p) { TYPED::destruct(p); }
1052 void on_copy_element(::collection::index i,
const TYPE * p) { TYPED::copy(&this->m_begin[i], p); }
1060 inline const TYPE & operator[](::collection::index i)
const {
return this->m_begin[i]; }
1061 inline TYPE & operator[](::collection::index i) {
return this->m_begin[i]; }
1064 TYPE * raw_allocate_at(::collection::index i, ::collection::count c);
1067 TYPE & insert_at(::collection::index nIndex,
const TYPE & newElement, ::collection::count nCount = 1);
1068 TYPE * insert_at(::collection::index nStartIndex,
const TYPE * p, ::collection::count nCount = 1);
1070 TYPE & insert_at_grow(::collection::index nIndex,
const TYPE &newElement, ::collection::count nCount = 1);
1071 TYPE * insert_at_grow(::collection::index nStartIndex,
const TYPE *p, ::collection::count nCount = 1);
1073 TYPE * insert_array_at(::collection::index nStartIndex,
const base_array * pNewArray);
1076 ::collection::index
erase_at(::collection::index nIndex, ::collection::count nCount = 1);
1079 template <
typename EQUAL_TYPE >
1080 ::collection::index
erase_at(
const EQUAL_TYPE *p, ::collection::count nCount = 1)
1081 requires(::std::is_same < EQUAL_TYPE, TYPE >::value) {
1082 return this->
erase_at(index_of(p), nCount);
1089 TYPE pick_at(::collection::index nIndex);
1090 TYPE pick_first(::collection::index nIndex = 0) { return ::transfer(pick_at(nIndex)); }
1091 TYPE pick_last(::collection::index nIndex = -1) { return ::transfer(pick_at(this->size() + nIndex)); }
1092 base_array pick_at(::collection::index nIndex, ::collection::count nCount);
1095 ::collection::index index_of(
const TYPE * p)
const {
auto i = p - this->m_begin;
return i >= 0 && i < this->size() ? i : -1; }
1098 bool erase(
const TYPE * p) {
auto i = index_of(p);
if (not_found(i))
return false;
return found(
erase_at(i)); }
1099 ::collection::count erase(
const TYPE * begin,
const TYPE * end);
1101 iterator erase(iterator p)
1110 template <
typename ITERATOR2 >
1111 inline void erase(
const ITERATOR2 & begin,
const ITERATOR2 & last);
1114 inline TYPE pop(::collection::index i = -1);
1115 inline ::collection::index push(ARG_TYPE newElement);
1116 inline void pop_last(::collection::index i = -1);
1117 inline TYPE & add_item(ARG_TYPE newElement);
1118 inline TYPE & add(ARG_TYPE newElement) {
return this->add_item(newElement); }
1119 inline TYPE& add_new();
1122 inline TYPE pop_first(::collection::index i = 0);
1124 inline TYPE takeAt(::collection::index i);
1125 inline TYPE takeFirst(::collection::index i = 0);
1126 inline TYPE takeLast(::collection::index i = -1);
1129 template <
typename CONTAINER >
1130 ::collection::count append_container(
const CONTAINER & container);
1131 ::collection::count append_initializer_list(const ::std::initializer_list < TYPE > & list_base);
1132 ::collection::count append(
const TYPE * p, ::collection::count c);
1133 ::collection::count append_element(
const TYPE & t, ::collection::count c);
1134 ::collection::count append(
const base_array & src);
1135 ::collection::count rear_append(
const TYPE * p, ::collection::count c);
1136 ::collection::count rear_append(
const base_array & src);
1137 template <
typename CONTAINER >
1138 void copy_container(
const CONTAINER & container);
1139 void copy_initializer_list(const ::std::initializer_list < TYPE > & list_base);
1140 void copy_element(
const TYPE & t, ::collection::count c);
1141 void copy(
const TYPE * p, ::collection::count c);
1142 void copy(
const base_array & src);
1144 void assign_element(
const TYPE & t, ::collection::count c)
1146 this->copy_element(t, c);
1150 void assign(
const TYPE * p, ::collection::count c);
1177 template <
typename PRED >
1178 ::collection::count predicate_each(PRED pred, ::collection::index iStart = 0, ::collection::count c = -1)
1181 ::collection::index iEnd = c < 0 ? get_count() + c : iStart + c - 1;
1183 ::i32 cProcessed = 0;
1185 for (::collection::index i = iStart; i <= iEnd; i++)
1188 pred(this->m_begin[i]);
1198 template <
typename PRED >
1199 ::collection::count predicate_each(PRED pred, ::collection::index iStart = 0, ::collection::count c = -1)
const
1202 return ((base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >*)
this)->predicate_each(pred, iStart, c);
1207 inline bool is_index_ok(::collection::index iIndex)
const {
return iIndex >= 0 && iIndex < get_count(); }
1210 inline bool is_last_index(::collection::index iIndex)
const {
return iIndex >= this->get_upper_bound(); }
1213 template <
typename PRED >
1214 bool predicate_contains(PRED pred, ::collection::index iStart = 0, ::collection::index iEnd = -1)
const
1217 return this->predicate_find_first(pred, iStart, iEnd) >= 0;
1221 template <
typename OTHER_IS_PTR >
1222 TYPE_IS_PTR get_existing_defer_add(
const OTHER_IS_PTR & p)
1225 for (::collection::index i = 0; i < this->get_count(); i++)
1228 auto & pelementHere = this->element_at(i);
1230 if (pelementHere == p)
1233 return pelementHere;
1236 else if (*pelementHere == *p)
1239 return pelementHere;
1252 template <
typename OTHER_IS_PTR >
1253 void defer_use_existing(OTHER_IS_PTR & p)
1256 for (::collection::index i = 0; i < this->get_count(); i++)
1259 auto & pelementHere = this->element_at(i);
1261 if (pelementHere == p)
1267 else if (*pelementHere == *p)
1283 template <
typename OTHER_IS_PTR >
1284 TYPE_IS_PTR get_existing(
const OTHER_IS_PTR & p)
const
1287 for (::collection::index i = 0; i < this->get_count(); i++)
1290 auto & pelementHere = this->element_at(i);
1292 if (pelementHere == p)
1295 return pelementHere;
1298 else if (*pelementHere == *p)
1301 return pelementHere;
1312 template <
typename OBJECT,
typename ATTRIBUTE >
1313 TYPE_IS_PTR merge_get_existing(
const TYPE_IS_PTR & p,
const OBJECT& pparticle,
const ATTRIBUTE& attribute)
1316 auto pModified = allocateø
typename TYPE_IS_PTR::TYPE (*p);
1318 pModified->process(pparticle, attribute);
1320 return this->get_existing(pModified);
1325 template <
typename PRED >
1326 ::collection::index predicate_find_first(PRED pred, ::collection::index iStart = 0, ::collection::index iEnd = -1)
const
1332 iEnd += get_count();
1336 if (iEnd >= get_count())
1339 iEnd = get_count() - 1;
1343 for (::collection::index i = iStart; i <= iEnd; i++)
1346 if (pred(this->m_begin[i]))
1360 template <
typename PRED >
1361 ::collection::index predicate_find_last(PRED pred, ::collection::index iLast = -1)
1367 iLast += get_count();
1371 for (::collection::index i = iLast; i >= 0; i--)
1374 if (pred(this->m_begin[i]))
1388 template <
typename PRED >
1389 TYPE * predicate_get_first(PRED pred)
1392 for (::i32 i = 0; i < get_count(); i++)
1395 if (pred(this->m_begin[i]))
1398 return &this->element_at(i);
1409 template <
typename PRED >
1410 ::collection::count predicate_get_count(PRED pred)
1413 ::collection::count c = 0;
1415 for (::i32 i = 0; i < get_count(); i++)
1418 if (pred(this->m_begin[i]))
1432 template <
typename PRED >
1433 ::collection::count predicate_erase(PRED pred)
1436 ::collection::count cTotal = 0;
1438 for (::i32 i = 0; i < get_count();)
1441 if (!pred(this->m_begin[i]))
1456 for (; i < get_count();)
1459 if (!pred(this->m_begin[i]))
1487 template <
typename F >
1491 for (::collection::index i = 0; i < get_count(); i++)
1494 f(this->m_begin[i]);
1501 template <
typename PRED >
1502 void predicate_sort(PRED pred);
1505 template <
typename T,
typename PRED >
1506 ::collection::index predicate_binary_search(
const T & t, PRED pred)
const;
1509 inline bool valid_iter(iterator first, iterator last)
1512 return first < last;
1517 inline bool rvalid_iter(iterator first, iterator last)
1520 return first > last;
1525 inline TYPE& operator%(::collection::index nIndex)
1528 return this->element_at(nIndex% this->get_size());
1533 inline const TYPE& operator%(::collection::index nIndex)
const
1536 return this->element_at(nIndex% this->get_size());
1541 bool is_version(::collection::index i)
1609template < prototype_
integral INTEGRAL,
class TYPE,
class ARG_TYPE,
class TYPED = ::typed::nodef < TYPE >,
class MEMORY = ::heap::typed_memory < TYPE, ::heap::e_memory_array >, ::enum_type t_etypeContainer = e_type_element >
1610inline TYPE& operator%(INTEGRAL nIndex,
const base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & a)
1613 return (TYPE &) (a % nIndex);
1620template<
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer>
1623base_array<TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer>::base_array() :
1629 m_countAllocation = 0;
1630 m_countAllocationOffset = 0;
1634template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1637base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::base_array(const ::enum_range & erange, ::collection::count c) :
1638 ARRAY_RANGE(
nullptr,
nullptr, erange)
1642 m_countAllocation = 0;
1643 m_countAllocationOffset = 0;
1664template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1665base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::base_array(
const std::initializer_list < TYPE > & initializer_list) :
1669 for (
auto &
item : initializer_list)
1701template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1702base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::~base_array ()
1710template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1711::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::resize(::collection::count nNewSize, ARG_TYPE t)
1714 return allocate(nNewSize,
false,
false, t);
1719template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1720::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::allocate_in_bytes(::collection::count nNewSize,
bool bShrink,
bool bRaw)
1723 return allocate((nNewSize +
sizeof(TYPE)) /
sizeof(TYPE), bShrink, bRaw);
1728template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1732 if (!this->prepare_first_in_count_last_out(first, in_count_out_last))
1748 auto nEraseCount = in_count_out_last - first + 1;
1750 auto sizeOld = this->size();
1759 TYPED::destruct_count(this->m_begin + first, nEraseCount);
1764 if (first == 0 && sizeOld > nEraseCount)
1767 m_countAllocationOffset -= nEraseCount;
1769 this->m_begin += nEraseCount;
1789 auto nTransferCount = sizeOld - (first + nEraseCount);
1791 if (nTransferCount > 0)
1794 ::safe_memory_transfer2(this->m_begin + first, nTransferCount, this->m_begin + first + nEraseCount,
1795 (memsize)nTransferCount);
1800 this->m_end -= nEraseCount;
1809template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1810void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::defer_erase_allocation_offset()
1813 if (this->m_countAllocationOffset >= 0)
1820 auto size = this->size();
1821 auto pNewBeg = this->m_begin + this->m_countAllocationOffset;
1822 auto pNewEnd = this->m_end + this->m_countAllocationOffset;
1824 ::safe_memory_transfer2(pNewBeg, this->m_countAllocation, this->m_begin, size);
1826 this->m_begin = pNewBeg;
1827 this->m_end = pNewEnd;
1828 this->m_countAllocationOffset = 0;
1833template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1834void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::free_extra()
1837 auto size = this->size();
1839 auto sizeNew = size;
1844 if(sizeNew != m_countAllocation)
1851 ASSERT(sizeNew <= SIZE_T_MAX /
sizeof(TYPE));
1855 TYPE* pNewData =
nullptr;
1862#if defined(__MCRTDBG) || MEMDLEAK
1866 if (::get_task() !=
nullptr)
1869 if (::get_task()->m_strFile.has_character())
1872 pNewData = MEMORY::allocate(size, ::get_task()->m_strFile, ::get_task()->m_iLine);
1878 pNewData = MEMORY::allocate(size, __FILE__, __LINE__);
1886 pNewData = MEMORY::allocate(size, __FILE__, __LINE__);
1892 if (::get_task_object_debug().has_character())
1895 pNewData = MEMORY::allocate(size, ::get_task_object_debug(), 0);
1901 pNewData = MEMORY::allocate(size, __FILE__, __LINE__);
1909 pNewData = MEMORY::allocate(sizeNew, &sizeNew);
1914 ::safe_memory_copy2(pNewData, (
size_t)size,this->m_begin, (
size_t)size);
1919 MEMORY::free(this->m_begin);
1921 this->m_begin = pNewData;
1923 m_countAllocation = sizeNew;
1925 this->m_end = this->m_begin + size;
1935template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1936void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::destroy()
1939 if(this->m_begin !=
nullptr)
1942 auto size = this->size();
1944 TYPED::destruct_count(this->m_begin, size);
1949 MEMORY::free(this->m_begin + this->m_countAllocationOffset);
1950 this->m_begin =
nullptr;
1951 this->m_end =
nullptr;
1952 this->m_countAllocation = 0;
1953 this->m_countAllocationOffset = 0;
1969template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1970TYPE * base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_allocate_at(::collection::index i, ::collection::count c)
1973 auto newSize = this->size() + c;
1975 auto nMove = this->size() - i;
1977 this->allocate(newSize,
false,
true);
1979 ::safe_memory_transfer2(this->m_begin + i + c, (
size_t) (nMove), this->m_begin + i, (
size_t) (nMove));
1981 return this->m_begin + i;
1986template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1987TYPE & base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_at(::collection::index i,
const TYPE & element, ::collection::count c)
1990 auto p = this->raw_allocate_at(i, c);
1992 TYPED::copy_construct_count(p, c, element);
1999template<
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer>
2000TYPE * base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_at(::collection::index i,
const TYPE * pelements, ::collection::count c)
2003 auto p = this->raw_allocate_at(i, c);
2005 TYPED::copy_construct_array(p, c, pelements);
2012template<
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer>
2013TYPE &base_array<TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer>::insert_at_grow(::collection::index i,
const TYPE &element,
2014 ::collection::count c)
2019 if (i > this->size())
2026 return this->insert_at(i, element, c);
2031template<
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer>
2032TYPE *base_array<TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer>::insert_at_grow(::collection::index i,
2033 const TYPE *pelements,
2034 ::collection::count c)
2039 if (i > this->size())
2045 return this->insert_at(i, pelements, c);
2049template<
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer>
2050TYPE * base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_array_at(::collection::index i,
const base_array * p)
2053 return this->insert_at(i, p->m_begin, p->size());
2108template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2109template <
typename CONTAINER >
2110::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append_container(
const CONTAINER & container)
2113 ::collection::count nOldSize = this->size();
2115 for (
auto&
item : container)
2118 add((ARG_TYPE)
item);
2127template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2128::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append_initializer_list(const ::std::initializer_list < TYPE >&
list_base)
2136template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2137::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append_element(
const TYPE & t, ::collection::count c)
2140 ::collection::count nOldSize = this->size();
2142 ::collection::count nSrcSize = c;
2144 allocate(nOldSize + nSrcSize,
false,
true);
2146 TYPED::copy_construct_count((this->m_begin + nOldSize), nSrcSize, t);
2153template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2154::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append(
const TYPE * p, ::collection::count c)
2157 ::collection::count nOldSize = this->size();
2159 ::collection::count nSrcSize = c;
2161 allocate(nOldSize + nSrcSize,
false,
true);
2163 TYPED::copy_construct_array((this->m_begin + nOldSize), nSrcSize, p);
2170template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2171void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::assign(
const TYPE * p, ::collection::count c)
2174 ::collection::count nOldSize = this->size();
2176 ::collection::count nSrcSize = c;
2178 allocate(nOldSize + nSrcSize,
false,
true);
2180 TYPED::copy_construct_array((this->m_begin + nOldSize), nSrcSize, p);
2188template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2189::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append(
const base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & src)
2192 return append(src.data(), src.size());
2197template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2198::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::rear_append(
const TYPE * p, ::collection::count c)
2201 ::collection::count nOldSize = this->size();
2203 ::collection::count nSrcSize = c;
2205 allocate(nOldSize + nSrcSize,
false,
true);
2207 TYPED::rear_copy_construct_count((this->m_begin + nOldSize), nSrcSize, p);
2214template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2215::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::rear_append(
const base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & src)
2218 return rear_append(src.data(), src.size());
2223template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2224template <
typename CONTAINER >
2225void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy_container(
const CONTAINER & container)
2230 append_initializer_list(container);
2235template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2236void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy_initializer_list(const ::std::initializer_list < TYPE >&
list_base)
2244template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2245void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy(
const TYPE * p, ::collection::count c)
2248 if(this->data() == p)
2251 if (c > this->size())
2254 throw_exception(error_wrong_state);
2257 else if (c < this->size())
2275template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2276void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy_element(
const TYPE & t, ::collection::count c)
2279 if(this->data() == &t)
2282 if (c > this->size())
2285 throw_exception(error_wrong_state);
2288 else if (c < this->size())
2301 append_element(t, c);
2306template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2307void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy(
const base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >& src)
2310 assign(src.data(), src.size());
2333template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2334template < prototype_array ARRAY >
2335void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_indexes(
const ARRAY & ia)
2340 for(::collection::index i = ia.get_upper_bound(); i >= 0; i--)
2350template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2351template < prototype_array ARRAY >
2352void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_descending_indexes(
const ARRAY & ia)
2355 for(::collection::index i = 0; i < ia.get_count(); i++)
2427template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2428TYPE base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pick_at(::collection::index nIndex)
2431 ::collection::count nCount = 1;
2433 ::collection::index nUpperBound = nIndex + nCount;
2435 if (nIndex < 0 || nCount < 0 || (nUpperBound > this->size()) || (nUpperBound < nIndex) || (nUpperBound < nCount))
2438 throw_exception(error_bad_argument);
2442 ::collection::count nMoveCount = this->size() - (nUpperBound);
2444 auto t = ::transfer(this->m_begin[nIndex]);
2451 ::safe_memory_transfer2(this->m_begin + nIndex, (
size_t)nMoveCount, this->m_begin + nUpperBound, (
size_t)nMoveCount);
2455 this->m_end -= nCount;
2457 return ::transfer(t);
2462template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2463base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pick_at(::collection::index nIndex, ::collection::count nCount)
2468 ::collection::index nUpperBound = nIndex + nCount;
2470 if (nIndex < 0 || nCount < 0 || (nUpperBound > this->size()) || (nUpperBound < nIndex) || (nUpperBound < nCount))
2473 throw_exception(error_bad_argument);
2477 ::collection::count nMoveCount = this->size() - (nUpperBound);
2479 base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > a(this->m_begin + nIndex, (
size_t)nMoveCount);
2481 TYPED::destruct_count(this->m_begin + nIndex, nCount);
2493 ::safe_memory_transfer2(this->m_begin + nIndex, (
size_t)nMoveCount, this->m_begin + nUpperBound, (
size_t)nMoveCount);
2497 this->m_end -= nCount;
2695template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2696void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::reserve(::collection::count newAllocationSize)
2699 if(newAllocationSize <= m_countAllocation)
2706 if(m_countAllocation <= 0)
2709 ASSERT(this->m_begin ==
nullptr && this->m_end ==
nullptr);
2711 if(newAllocationSize > UPTR_MAXIMUM /
sizeof(TYPE))
2714 throw_exception(error_no_memory);
2718 newAllocationSize = maximum(newAllocationSize, m_countAddUp);
2720#if MEMDLEAK || defined(__MCRTDBG)
2722 if(::get_task() !=
nullptr)
2725#if defined(__MCRTDBG)
2727 if(::get_task()->m_strFile.has_character())
2730 this->m_begin = MEMORY::allocate(newAllocationSize, ::get_task()->m_strFile, ::get_task()->m_iLine);
2736 this->m_begin = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2742 if (::get_task_object_debug().has_character())
2745 this->m_begin = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
2751 this->m_begin = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
2761 this->m_begin = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2767 this->m_begin = MEMORY::allocate(newAllocationSize, &newAllocationSize);
2771 this->m_end = this->m_begin;
2777 auto countOld = this->size();
2779 auto countAddUp = m_countAddUp;
2784 countAddUp = this->size();
2786 constrain(countAddUp, 4, 1024);
2790 if(newAllocationSize < m_countAllocation + countAddUp)
2793 newAllocationSize = m_countAllocation + countAddUp;
2797 if(newAllocationSize > UPTR_MAXIMUM /
sizeof(TYPE))
2800 throw_exception(error_no_memory);
2804#if MEMDLEAK || defined(__MCRTDBG)
2806 TYPE* pNewData =
nullptr;
2808 if(::get_task() !=
nullptr)
2811#if defined(__MCRTDBG)
2813 if(::get_task()->m_strFile.has_character())
2816 pNewData = MEMORY::allocate(newAllocationSize, ::get_task()->m_strFile,::get_task()->m_iLine);
2822 pNewData = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2828 if (::get_task_object_debug().has_character())
2831 pNewData = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
2837 pNewData = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
2847 pNewData = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2853 TYPE * pNewData = MEMORY::allocate(newAllocationSize, &newAllocationSize);
2858 ::safe_memory_copy2(pNewData, (
size_t)newAllocationSize, this->m_begin, (
size_t) this->size());
2863 MEMORY::free(this->m_begin);
2870 this->m_begin = pNewData;
2872 this->m_end = this->m_begin + countOld;
2876 m_countAllocation = newAllocationSize;
3182template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3183inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::set_at_grow(::collection::index nIndex, ARG_TYPE newElement)
3186 ASSERT(nIndex >= 0);
3188 if (nIndex >= this->size())
3191 this->set_size(nIndex + 1);
3195 this->m_begin[nIndex] = newElement;
3200template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3201inline TYPE & base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::element_at_grow(::collection::index nIndex)
3204 ASSERT(nIndex >= 0);
3206 if (nIndex >= this->size())
3209 this->set_size(nIndex + 1);
3213 return this->m_begin[nIndex];
3218template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3219inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::set_each(ARG_TYPE element, ::collection::index first, ::collection::count in_count_out_last)
3222 this->prepare_first_in_count_last_out(first, in_count_out_last);
3224 for(::collection::index i = first; i <= in_count_out_last; i++)
3227 this->m_begin[i] = element;
3234template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3235template <
typename ITERATOR2 >
3236inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase(
const ITERATOR2 & begin,
const ITERATOR2 & last)
3239 auto start = this->index_of(begin);
3241 auto end = this->index_of(last);
3243 if(start < 0 || (end <= start && end >= 0))
3250 auto count = end > start ? end - start : -1;
3252 erase_at(start, count);
3266template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3267inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_size()
const
3269 return (::collection::count) this->size();
3273template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3274inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_count()
const
3276 return (::collection::count) this->size();
3280template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3281inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_length()
const
3283 return (::collection::count) this->size();
3287template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3288inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_size_in_bytes()
const
3290 return (::collection::count)this->size() *
sizeof(TYPE);
3294template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3295inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_byte_count()
const
3297 return (::collection::count) (this->size() *
sizeof(TYPE));
3308template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3309inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::count()
const
3311 return this->get_count();
3314template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3315inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::length()
const
3317 return this->get_length();
3346template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3347inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase_all()
3350 return allocate(0,
false,
false);
3355template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3356inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::set_size(::collection::index nNewSize)
3359 return allocate(nNewSize,
false,
false);
3364template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3365inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::clear()
3373template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3374inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase_first(::collection::count c)
3377 ASSERT(this->size() >= c);
3384template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3385inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase_last(::collection::count c)
3388 ASSERT(this->size() >= c);
3390 this->erase_at(this->get_upper_bound(-c), c);
3395template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3396inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::zero(::collection::index iStart,::collection::count c)
3400 c = get_size() - iStart;
3402 ::zero(&this->m_begin[iStart],c *
sizeof(TYPE));
3483template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3484inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::__swap(::collection::index index1, ::collection::index index2)
3487 ::__swap(this->m_begin[index1], this->m_begin[index2]);
3492template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3493inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::__swap(
iterator it1,
iterator it2)
3506template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3507inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::__swap(const_iterator it1, const_iterator it2)
3510 auto t = (TYPE) *it1;
3512 ((TYPE &)*it1) = (
const TYPE &) *it2;
3520template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3521void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::set_all(
const TYPE & t)
3524 for (::collection::index i = 0; i < get_count(); i++)
3527 this->m_begin[i] = t;
3560template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3561inline TYPE base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop(::collection::index n)
3564 ::collection::index i = this->get_upper_bound(n);
3566 TYPE t = this->element_at(i);
3574template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3575inline TYPE base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop_first(::collection::index i)
3578 auto t = ::transfer(this->first(i));
3587template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3588inline void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop_last(::collection::index n)
3591 erase_at(this->get_upper_bound(n));
3596template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3597inline ::collection::index base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::push(ARG_TYPE newElement)
3600 return index_of(&insert_at(this->size(), newElement));
3605template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3606inline TYPE& base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add_item(ARG_TYPE newElement)
3609 auto nIndex = this->size();
3611 this->allocate(nIndex + 1,
false,
false, newElement);
3613 return this->element_at(nIndex);
3618template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3619TYPE& base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add_new()
3622 auto nIndex = this->size();
3624 this->allocate(nIndex + 1,
false,
false);
3626 return this->last();
3640template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3641inline TYPE base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::takeAt(::collection::index i)
3644 TYPE t = this->element_at(i);
3653template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3654inline TYPE base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::takeFirst(::collection::index i)
3657 TYPE t = this->element_at(i);
3666template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3667inline TYPE base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::takeLast(::collection::index n)
3670 ::collection::index i = this->get_upper_bound(n);
3672 TYPE t = this->element_at(i);
3691template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3692template <
typename OTHER_TYPE >
3693base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::base_array(::collection::count c,
const OTHER_TYPE * p)
3694 requires (::std::is_convertible_v < OTHER_TYPE, CONTAINER_ITEM_TYPE >) :
3700 for (::collection::index i = 0; i < c; i++)
3703 this->element_at(i) = p[i];
3713template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3714inline ::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase(
const TYPE * begin,
const TYPE * last)
3717 auto iStart = index_of(begin);
3719 auto iEnd = index_of(last);
3722 return erase_at(iStart, iEnd - iStart);
Definition array_range.h:15
Definition base_array.h:112
::collection::count allocate(::collection::count nNewSize, bool bShrink, bool bRaw, P &p)
if bRaw is true does not call default constructors on ___new elements
Definition base_array.h:972
::collection::index erase_at(::collection::index nIndex, ::collection::count nCount=1)
Definition aaa__array_base_impl.h:62
Definition rear_iterator.h:9
Definition _initial_concepts.h:1023
Definition _forward_declaration.h:1308
Definition base_array.h:3728
Definition std_iterator.h:49
Definition base_array.h:100