5#include "acme/memory/typed.h"
6#include "acme/memory/typed_memory.h"
7#include "acme/memory/operation.h"
10CLASS_DECL_ACME ::string get_task_object_name();
14CLASS_DECL_ACME ::string get_task_object_debug();
19#define __default_array_array_base_non_particle(TYPE) ::array_base_quantum < TYPE, const TYPE &, ::allocator::def < TYPE > >
22#define DECLARE_TYPED_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE, CONTAINER_TYPE) \
23::pointer<TYPE>& ITEM ## _at(::collection::index i) { return CONTAINER[i]; } \
24const TYPE * ITEM ## _at(::collection::index i) const { return CONTAINER[i]; } \
25::pointer<TYPE>* ITEM ## _data() { return CONTAINER.data(); } \
26::pointer<TYPE>const * ITEM ## _data() const { return CONTAINER.data(); } \
27TYPE * get_ ## ITEM(::collection::index i) const { return CONTAINER.bounds(i) ? CONTAINER[i] : nullptr; } \
28::collection::count ITEM ## _count() const { return CONTAINER.get_count(); } \
29bool has_ ## ITEM() const { return CONTAINER.has_element(); } \
30const CONTAINER_TYPE & ITEM ## a() const { return CONTAINER; } \
31CONTAINER_TYPE & ITEM ## a() { return CONTAINER; } \
32bool contains_ ## ITEM(const TYPE * p) const { return CONTAINER.contains(p); } \
33bool is_there_no_ ## ITEM() const { return CONTAINER.is_empty(); } \
34bool has_no_ ## ITEM() const { return is_there_no_ ## ITEM(); } \
35::collection::index find_first_ ## ITEM(const TYPE * p, ::collection::index iStart = 0, ::collection::count nCount = -1) const { return CONTAINER.find_first(p, iStart, nCount); } \
36::pointer<TYPE>& first_ ## ITEM() { return CONTAINER.first_pointer(); } \
37::pointer<TYPE>& last_ ## ITEM() { return CONTAINER.last_pointer(); } \
38TYPE * get_first_ ## ITEM() const { return CONTAINER.get_first_pointer(); } \
39TYPE * get_last_ ## ITEM() const { return CONTAINER.get_last_pointer(); } \
40::collection::index ITEM ## _first_index(::collection::index i = 0) const { return CONTAINER.first_index(i); } \
41::collection::index ITEM ## _last_index(::collection::index i = -1) const { return CONTAINER.last_index(i); } \
42CONTAINER_TYPE CONTAINER
44#define DECLARE_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE) \
45DECLARE_TYPED_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE, pointer_array < TYPE >)
47#define DECLARE_TYPED_ARRAY_OF(ITEM, CONTAINER, TYPE, CONTAINER_TYPE) \
48::collection::index add_ ## ITEM(TYPE * p) { return CONTAINER.add_item(p); } \
49::collection::index add_ ## ITEM ## _array(const CONTAINER_TYPE & a) { return CONTAINER.append(a); } \
50::collection::index add_unique_ ## ITEM(TYPE * p) { return CONTAINER.add_unique(p); } \
51::collection::index add_unique_ ## ITEM ## _array(const CONTAINER_TYPE & a) { return CONTAINER.add_unique(a); } \
52::collection::index erase_ ## ITEM(TYPE * p) { return CONTAINER.erase(p); } \
53CONTAINER_TYPE ITEM ## a_section(::collection::index iStart = 0, ::collection::count nCount = -1){return CONTAINER.slice < CONTAINER_TYPE >(iStart, nCount);} \
54template < typename ARRAY > \
55void ITEM ## a_slice(ARRAY & a, ::collection::index iStart = 0, ::collection::count nCount = -1){ CONTAINER.slice(a, iStart, nCount);} \
56DECLARE_TYPED_ARRAY_ACCESSOR_OF(ITEM, CONTAINER, TYPE, CONTAINER_TYPE)
58#define HAVE_ARRAY_OF(ITEM, CONTAINER, TYPE) \
59DECLARE_TYPED_ARRAY_OF(ITEM, CONTAINER, TYPE, pointer_array < TYPE >)
61#define DECLARE_ARRAY_CONTAINER_OF(ARRAY, ITEM, CONTAINER, TYPE) \
62ARRAY(const ::std::initializer_list < ::pointer<TYPE >>& list) : CONTAINER(list) { } \
63DECLARE_TYPED_ARRAY_OF(ITEM, CONTAINER, TYPE, pointer_array < TYPE >)
65#define DECLARE_ARRAY_OF(ARRAY, ITEM, TYPE) \
66DECLARE_ARRAY_CONTAINER_OF(ARRAY, ITEM, m_ ## ITEM ## a, TYPE)
68template <
typename TYPE >
69class pointer_rear_iterator
74 using ITEM = non_const < TYPE >;
75 using ITEM_POINTER = ITEM *;
77 using iterator = ::pointer_rear_iterator < ITEM >;
78 using const_iterator = ::pointer_rear_iterator < const ITEM >;
84 pointer_rear_iterator() { m_p =
nullptr; }
85 pointer_rear_iterator(
const ITEM * p) { m_p = (TYPE *) p; }
86 pointer_rear_iterator(
const iterator & i) { m_p = (TYPE *)i.m_p; }
87 pointer_rear_iterator(
const const_iterator & i) { m_p = (TYPE *)i.m_p; }
90 auto& operator *() {
return *m_p; }
91 auto& operator *()
const {
return *m_p; }
92 auto operator ->() {
return m_p; }
93 auto operator ->()
const {
return m_p; }
95 pointer_rear_iterator & operator ++()
101 pointer_rear_iterator& operator --()
108 pointer_rear_iterator operator ++(
int)
116 pointer_rear_iterator operator --(
int)
124 template < primitive_
integral INTEGRAL >
125 pointer_rear_iterator operator +(INTEGRAL i)
131 template < primitive_
integral INTEGRAL >
132 pointer_rear_iterator operator -(INTEGRAL i)
139 template < primitive_
integral INTEGRAL >
140 pointer_rear_iterator & operator +=(INTEGRAL i)
146 template < primitive_
integral INTEGRAL >
147 pointer_rear_iterator & operator -=(INTEGRAL i)
155 bool operator ==(
const pointer_rear_iterator& p)
const {
return m_p == p.m_p; }
156 bool operator ==(
const TYPE * p)
const {
return m_p == p; }
157 ::std::strong_ordering operator <=>(
const pointer_rear_iterator& p)
const {
return this->m_p <=> p.m_p; }
159 ::collection::count operator - (
const pointer_rear_iterator& p)
const {
return this->m_p - p.m_p; }
69class pointer_rear_iterator {
…};
164template <
typename A,
typename B >
165auto distance(
const pointer_rear_iterator < A > & a,
const pointer_rear_iterator < B > & b) {
return (a < b) ? (b - a) : (a - b); }
166template <
typename A,
typename B >
167auto distance(
const A * pa,
const B * pb) {
return (pa < pb) ? (pb - pa) : (pa - pb); }
173template <
class TYPE,
class ARG_TYPE,
class TYPED,
class MEMORY, ::enum_type t_etypeContainer >
174class array_base_quantum :
176 public ::range < TYPE * >,
187 using ARRAY_RANGE = ::range < TYPE * >;
188 using array_range = ::range < TYPE * >;
192 using CONTAINER_ITEM_TYPE = TYPE;
193 using TYPE_IS_PTR = TYPE;
195 using this_iterator =
typename ARRAY_RANGE::this_iterator;
196 using iterator =
typename ARRAY_RANGE::iterator;
197 using const_iterator =
typename ARRAY_RANGE::const_iterator;
200 ::collection::count m_countAllocation;
201 ::collection::count m_countAddUp;
202 ::collection::count m_countAllocationOffset;
205 array_base_quantum();
206 array_base_quantum(std::initializer_list < TYPE > initializer_list);
207 array_base_quantum(
const array_base_quantum & a);
208 array_base_quantum(array_base_quantum && a)
noexcept;
209 array_base_quantum(
const TYPE * p, ::collection::count c);
210 array_base_quantum(::range < const_iterator > constrange) : array_base_quantum(constrange.begin(), constrange.end()) {}
211 template < primitive_
integral INTEGRAL >
212 array_base_quantum(const_iterator begin, INTEGRAL count) : array_base_quantum(begin, begin + count) {}
213 array_base_quantum(const_iterator begin, const_iterator end)
215 auto p = this->begin();
216 while (p != end) add(*p);
218 ~array_base_quantum()
override;
221 void defer_erase_allocation_offset();
226 if (this->m_begin !=
nullptr)
236 array_base_quantum & operator = (
const array_base_quantum & a)
246 auto ptarget = this->data();
248 auto psource = a.data();
270 array_base_quantum & operator = (array_base_quantum && array_base_quantum)
273 if (
this != &array_base_quantum)
276 transfer(::transfer(array_base_quantum));
286 void add_initializer_list(const ::std::initializer_list < TYPE > & initializer_list)
289 for (
auto &
item : initializer_list)
299 inline array_base_quantum & transfer(array_base_quantum && a)
307 ARRAY_RANGE::operator=(::transfer(a));
309 m_countAddUp = a.m_countAddUp;
311 m_countAllocation = a.m_countAllocation;
320 inline ::range<rear_iterator> rear_payloads()
323 return ::range<rear_iterator>(this->rear_begin(), this->rear_end());
328 inline ::range<const_rear_iterator> rear_payloads()
const
331 return ::range<const_rear_iterator>(this->rear_begin(), this->rear_end());
639 inline memsize length_in_bytes()
const {
return this->size() *
sizeof(TYPE); }
669 inline bool contains_address(
const TYPE * pmatter)
const {
return pmatter >= this->m_begin && pmatter < this->end(); }
672 inline ::collection::count get_size()
const;
673 inline ::collection::count get_size_in_bytes()
const;
674 inline ::collection::count get_count()
const;
675 inline ::collection::count get_byte_count()
const;
676 inline ::collection::count get_length()
const;
678 inline ::collection::count count()
const;
679 inline ::collection::count length()
const;
680 inline ::collection::count byte_count()
const {
return get_byte_count(); }
683 inline bool has_element()
const noexcept {
return this->size() > 0; }
684 inline bool is_empty(::collection::count countMinimum = 0)
const noexcept {
return this->size() <= countMinimum; }
685 inline bool empty(::collection::count countMinimum = 0)
const noexcept {
return this->size() <= countMinimum; }
686 inline bool has_elements(::collection::count countMinimum = 1)
const noexcept {
return this->size() >= countMinimum; }
687 inline ::collection::index get_lower_bound(::collection::index i = 0)
const;
688 inline ::collection::index get_middle_index(::collection::index i = 0)
const;
689 inline ::collection::index get_upper_bound(::collection::index i = -1)
const;
690 inline ::collection::index lower_bound(::collection::index i = 0)
const {
return this->get_lower_bound(i); }
691 inline ::collection::index upper_bound(::collection::index i = -1)
const {
return this->get_upper_bound(i); }
692 inline ::collection::index first_index(::collection::index i = 0)
const {
return this->lower_bound(i); }
693 inline ::collection::index middle_index(::collection::index i = 0)
const {
return this->get_middle_index(i); }
694 inline ::collection::index last_index(::collection::index i = -1)
const {
return this->get_upper_bound(i); }
695 inline bool bounds(::collection::index i)
const;
696 inline bool contains_index(::collection::index i)
const {
return bounds(i); }
699 inline this_iterator back(::collection::index i = -1) {
return (this_iterator)(this->begin() + this->get_upper_bound(i)); }
700 inline const_iterator back(::collection::index i = -1)
const {
return (const_iterator)(this->begin() + this->get_upper_bound(i)); }
702 void ensure_index_ok(::collection::index nIndex)
const {
if (nIndex < 0 || nIndex >= this->size()) throw_exception(error_index_out_of_bounds); }
704 inline const TYPE * ptr_at(::collection::index nIndex)
const {
return this->m_begin + nIndex; }
705 inline TYPE * ptr_at(::collection::index nIndex) {
return this->m_begin + nIndex; }
707 inline const TYPE & element_at(::collection::index nIndex)
const;
708 inline TYPE & element_at(::collection::index nIndex);
710 inline const TYPE& at(::collection::index nIndex)
const { ensure_index_ok(nIndex);
return element_at(nIndex); }
711 inline TYPE& at(::collection::index nIndex) { ensure_index_ok(nIndex);
return element_at(nIndex); }
713 inline TYPE & first(::collection::index n = 0);
714 inline const TYPE & first(::collection::index n = 0)
const;
716 inline TYPE & last(::collection::index n = -1);
717 inline const TYPE & last(::collection::index n = -1)
const;
719 inline TYPE & middle(::collection::index n = 0);
720 inline const TYPE & middle(::collection::index n = 0)
const;
722 inline void set_at_grow(::collection::index nIndex, ARG_TYPE newElement);
723 inline TYPE & element_at_grow(::collection::index nIndex);
725 inline void set_each(ARG_TYPE element, ::collection::index iStart = 0, ::collection::count c = -1);
727 template < ::std::
size_t N >
728 TYPE & get() {
return element_at(N); }
731 void reserve(::collection::count newAllocationSize);
734 ::collection::count set_size(::collection::count nNewSize);
740 template < po
inter_not_castable_to < TYPE * > P >
741 ::collection::count
allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw, P & p)
744 return _allocate(nNewSize, bShrink, bRaw, &t);
741 ::collection::count
allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw, P & p) {
…}
746 template < po
inter_castable_to < TYPE * > T >
747 ::collection::count
allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw, T & t)
749 return _allocate(nNewSize, bShrink, bRaw, &t);
751 ::collection::count
allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw)
753 return _allocate(nNewSize, bShrink, bRaw,
nullptr);
755 ::collection::count _allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw,
const TYPE * type);
759 ::collection::count allocate_in_bytes(::collection::count nNewSize,
bool bShrink,
bool bRaw);
763 ::collection::count resize(::collection::count nNewSize) {
return set_size(nNewSize); }
764 ::collection::count resize(::collection::count nNewSize, ARG_TYPE t);
767 virtual void destroy();
769 inline void __swap(::collection::index index1, ::collection::index index2);
770 inline void __swap(iterator index1, iterator index2);
771 inline void __swap(const_iterator index1, const_iterator index2);
774 void set_all(
const TYPE & t);
777 rear_iterator rear_begin()
779 return this->m_end - 1;
782 rear_iterator rear_end()
784 return this->m_begin - 1;
787 const_rear_iterator rear_begin()
const
789 return (const_rear_iterator&)this->m_end - 1;
792 const_rear_iterator rear_end()
const
794 return (const_rear_iterator&)this->m_begin - 1;
798 void zero(::collection::index iStart = 0, ::collection::count c = -1);
803 template < primitive_array ARRAY >
804 void erase_indexes(
const ARRAY & ia);
806 template < primitive_array ARRAY >
807 void erase_descending_indexes(
const ARRAY & ia);
810 inline bool prepare_first_last(::collection::index & first, ::collection::index & last)
const;
811 inline bool prepare_first_in_count_last_out(::collection::index & first, ::collection::count & inCountLastOut)
const;
814 inline void erase_first(::collection::count c = 1);
815 inline void erase_last(::collection::count c = 1);
816 inline ::collection::count erase_all();
820 void on_construct_element(TYPE * p) { TYPED::construct(p); }
821 void on_construct_element(TYPE * p, ::collection::count c) { TYPED::construct_count(p, c); }
822 void on_destruct_element(TYPE * p) { TYPED::destruct(p); }
823 void on_copy_element(::collection::index i,
const TYPE * p) { TYPED::copy(&this->m_begin[i], p); }
831 inline const TYPE & operator[](::collection::index i)
const {
return this->m_begin[i]; }
832 inline TYPE & operator[](::collection::index i) {
return this->m_begin[i]; }
835 TYPE * raw_allocate_at(::collection::index i, ::collection::count c);
838 TYPE & insert_at(::collection::index nIndex,
const TYPE & newElement, ::collection::count nCount = 1);
839 TYPE * insert_at(::collection::index nStartIndex,
const TYPE * p, ::collection::count nCount = 1);
841 TYPE * insert_array_at(::collection::index nStartIndex,
const array_base_quantum * pNewArray);
844 ::collection::index erase_at(::collection::index nIndex, ::collection::count nCount = 1);
849 TYPE pick_at(::collection::index nIndex);
850 TYPE pick_first(::collection::index nIndex = 0) { return ::transfer(pick_at(nIndex)); }
851 TYPE pick_last(::collection::index nIndex = -1) { return ::transfer(pick_at(this->size() + nIndex)); }
852 array_base_quantum pick_at(::collection::index nIndex, ::collection::count nCount);
855 ::collection::index erase_item(TYPE * p);
857 ::collection::index index_of(
const TYPE * p)
const {
auto i = p - this->m_begin;
return i >= 0 && i < this->size() ? i : -1; }
860 bool erase(
const TYPE * p) {
auto i = index_of(p);
if (not_found(i))
return false;
return found(erase_at(i)); }
861 ::collection::count erase(
const TYPE * begin,
const TYPE * end);
863 iterator erase(iterator p)
866 this->erase_at(index_of(p));
872 template <
typename ITERATOR2 >
873 inline void erase(
const ITERATOR2 & begin,
const ITERATOR2 & last);
876 inline TYPE pop(::collection::index i = -1);
877 inline ::collection::index push(ARG_TYPE newElement);
878 inline void pop_back(::collection::index i = -1);
879 inline TYPE & add_item(ARG_TYPE newElement);
880 inline TYPE & add(ARG_TYPE newElement) {
return this->add_item(newElement); }
881 inline TYPE& add_new();
884 inline TYPE pop_first(::collection::index i = 0);
886 inline TYPE takeAt(::collection::index i);
887 inline TYPE takeFirst(::collection::index i = 0);
888 inline TYPE takeLast(::collection::index i = -1);
891 template <
typename CONTAINER >
892 ::collection::count append_container(
const CONTAINER & container);
893 ::collection::count append_initializer_list(const ::std::initializer_list < TYPE > & list);
894 virtual ::collection::count append(
const TYPE * p, ::collection::count c);
895 virtual ::collection::count append(
const array_base_quantum & src);
896 template <
typename CONTAINER >
897 void copy_container(
const CONTAINER & container);
898 void copy_initializer_list(const ::std::initializer_list < TYPE > & list);
899 virtual void copy(
const TYPE* p, ::collection::count c);
900 virtual void copy(
const array_base_quantum & src);
927 virtual void on_after_read();
929 template <
typename PRED >
930 ::collection::count predicate_each(PRED pred, ::collection::index iStart = 0, ::collection::count c = -1)
933 ::collection::index iEnd = c < 0 ? get_count() + c : iStart + c - 1;
937 for (::collection::index i = iStart; i <= iEnd; i++)
940 pred(this->m_begin[i]);
950 template <
typename PRED >
951 ::collection::count predicate_each(PRED pred, ::collection::index iStart = 0, ::collection::count c = -1)
const
954 return ((array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >*)
this)->predicate_each(pred, iStart, c);
959 inline bool is_index_ok(::collection::index iIndex)
const {
return iIndex >= 0 && iIndex < get_count(); }
962 inline bool is_last_index(::collection::index iIndex)
const {
return iIndex >= get_upper_bound(); }
965 template <
typename PRED >
966 bool predicate_contains(PRED pred, ::collection::index iStart = 0, ::collection::index iEnd = -1)
const
969 return this->predicate_find_first(pred, iStart, iEnd) >= 0;
973 template <
typename OTHER_IS_PTR >
974 TYPE_IS_PTR get_existing_defer_add(
const OTHER_IS_PTR & p)
977 for (::collection::index i = 0; i < this->get_count(); i++)
980 auto & pelementHere = this->element_at(i);
982 if (pelementHere == p)
988 else if (*pelementHere == *p)
1004 template <
typename OTHER_IS_PTR >
1005 void defer_use_existing(OTHER_IS_PTR & p)
1008 for (::collection::index i = 0; i < this->get_count(); i++)
1011 auto & pelementHere = this->element_at(i);
1013 if (pelementHere == p)
1019 else if (*pelementHere == *p)
1035 template <
typename OTHER_IS_PTR >
1036 TYPE_IS_PTR get_existing(
const OTHER_IS_PTR & p)
const
1039 for (::collection::index i = 0; i < this->get_count(); i++)
1042 auto & pelementHere = this->element_at(i);
1044 if (pelementHere == p)
1047 return pelementHere;
1050 else if (*pelementHere == *p)
1053 return pelementHere;
1064 template <
typename OBJECT,
typename ATTRIBUTE >
1065 TYPE_IS_PTR merge_get_existing(
const TYPE_IS_PTR & p,
const OBJECT& pparticle,
const ATTRIBUTE& attribute)
1068 auto pModified = __allocate
typename TYPE_IS_PTR::TYPE (*p);
1070 pModified->process(pparticle, attribute);
1072 return this->get_existing(pModified);
1077 template <
typename PRED >
1078 ::collection::index predicate_find_first(PRED pred, ::collection::index iStart = 0, ::collection::index iEnd = -1)
const
1084 iEnd += get_count();
1088 if (iEnd >= get_count())
1091 iEnd = get_count() - 1;
1095 for (::collection::index i = iStart; i <= iEnd; i++)
1098 if (pred(this->m_begin[i]))
1112 template <
typename PRED >
1113 ::collection::index predicate_find_last(PRED pred, ::collection::index iLast = -1)
1119 iLast += get_count();
1123 for (::collection::index i = iLast; i >= 0; i--)
1126 if (pred(this->m_begin[i]))
1140 template <
typename PRED >
1141 TYPE * predicate_get_first(PRED pred)
1144 for (
int i = 0; i < get_count(); i++)
1147 if (pred(this->m_begin[i]))
1150 return &element_at(i);
1161 template <
typename PRED >
1162 ::collection::count predicate_get_count(PRED pred)
1165 ::collection::count c = 0;
1167 for (
int i = 0; i < get_count(); i++)
1170 if (pred(this->m_begin[i]))
1184 template <
typename PRED >
1185 ::collection::count predicate_erase(PRED pred)
1188 ::collection::count cTotal = 0;
1190 for (
int i = 0; i < get_count();)
1193 if (!pred(this->m_begin[i]))
1208 for (; i < get_count();)
1211 if (!pred(this->m_begin[i]))
1224 erase_at(iStart, iCount);
1239 template <
typename F >
1243 for (::collection::index i = 0; i < get_count(); i++)
1246 f(this->m_begin[i]);
1253 template <
typename PRED >
1254 void predicate_sort(PRED pred);
1257 template <
typename T,
typename PRED >
1258 ::collection::index predicate_binary_search(
const T & t, PRED pred)
const;
1261 inline bool valid_iter(iterator first, iterator last)
1264 return first < last;
1269 inline bool rvalid_iter(iterator first, iterator last)
1272 return first > last;
1277 inline TYPE& operator%(::collection::index nIndex)
1280 return this->element_at(nIndex% this->get_size());
1285 inline const TYPE& operator%(::collection::index nIndex)
const
1288 return this->element_at(nIndex% this->get_size());
1293 bool is_version(::collection::index i)
174class array_base_quantum : {
…};
1361template < primitive_
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 >
1362inline TYPE& operator%(INTEGRAL nIndex,
const array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & a)
1365 return (TYPE &) (a % nIndex);
1374template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1375array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::array_base_quantum() :
1380 m_countAllocation = 0;
1381 m_countAllocationOffset = 0;
1385template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1386array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::array_base_quantum(
array_base_quantum &&
array) noexcept :
1390 this->m_countAddUp =
array.m_countAddUp;
1391 this->m_countAllocation =
array.m_countAllocation;
1392 this->m_countAllocationOffset =
array.m_countAllocationOffset;
1394 array.m_begin =
nullptr;
1396 array.m_countAllocation = 0;
1401template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1402array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::array_base_quantum(std::initializer_list<TYPE > initializer_list) :
1406 for (
auto & item : initializer_list)
1416template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1417array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::array_base_quantum(
const array_base_quantum &
array)
1421 this->m_begin =
nullptr;
1422 this->m_end =
nullptr;
1423 m_countAllocation = 0;
1424 m_countAllocationOffset = 0;
1425 set_size(
array.get_size());
1427 for (::collection::index i = 0; i <
array.get_size(); i++)
1430 element_at(i) =
array[i];
1438template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1439array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::~array_base_quantum ()
1447template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1448::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::resize(::collection::count nNewSize, ARG_TYPE t)
1451 return allocate(nNewSize,
false,
false, t);
1456template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1457::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::allocate_in_bytes(::collection::count nNewSize,
bool bShrink,
bool bRaw)
1460 return allocate((nNewSize +
sizeof(TYPE)) /
sizeof(TYPE), bShrink, bRaw);
1465template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1466::collection::index array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_at(::collection::index first, ::collection::count in_count_out_last)
1469 if (!prepare_first_in_count_last_out(first, in_count_out_last))
1478 auto nCount = in_count_out_last - first + 1;
1480 ::collection::count nMoveCount = this->size() - in_count_out_last;
1482 TYPED::destruct_count(this->m_begin + first, nCount);
1487 m_countAllocationOffset -= nCount;
1489 this->m_begin += nCount;
1498 ::safe_memory_transfer2(this->m_begin + first, nMoveCount, this->m_begin + in_count_out_last + 1, (
size_t)nMoveCount);
1502 this->m_end -= nCount;
1511template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1512void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::defer_erase_allocation_offset()
1515 if (this->m_countAllocationOffset >= 0)
1522 auto size = this->size();
1523 auto pNewBeg = this->m_begin + this->m_countAllocationOffset;
1524 auto pNewEnd = this->m_end + this->m_countAllocationOffset;
1526 ::safe_memory_transfer2(pNewBeg, this->m_countAllocation, this->m_begin, size);
1528 this->m_begin = pNewBeg;
1529 this->m_end = pNewEnd;
1530 this->m_countAllocationOffset = 0;
1535template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1536::collection::index array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_item(TYPE * p)
1539 return erase_at(p - this->m_begin);
1545template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1546void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::free_extra()
1549 auto size = this->size();
1551 auto sizeNew = size;
1553 if(sizeNew != m_countAllocation)
1560 ASSERT(sizeNew <= SIZE_T_MAX /
sizeof(TYPE));
1564 TYPE* pNewData =
nullptr;
1571#if defined(__MCRTDBG) || MEMDLEAK
1575 if (::get_task() !=
nullptr)
1578 if (::get_task()->m_strFile.has_character())
1581 pNewData = MEMORY::allocate(size, ::get_task()->m_strFile, ::get_task()->m_iLine);
1587 pNewData = MEMORY::allocate(size, __FILE__, __LINE__);
1595 pNewData = MEMORY::allocate(size, __FILE__, __LINE__);
1601 if (::get_task_object_debug().has_character())
1604 pNewData = MEMORY::allocate(size, ::get_task_object_debug(), 0);
1610 pNewData = MEMORY::allocate(size, __FILE__, __LINE__);
1618 pNewData = MEMORY::allocate(sizeNew, &sizeNew);
1623 ::safe_memory_copy2(pNewData, (
size_t)size,this->m_begin, (
size_t)size);
1628 MEMORY::free(this->m_begin);
1630 this->m_begin = pNewData;
1632 m_countAllocation = sizeNew;
1634 this->m_end = this->m_begin + size;
1642template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1643void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::destroy()
1646 if(this->m_begin !=
nullptr)
1649 auto size = this->size();
1651 TYPED::destruct_count(this->m_begin, size);
1653 MEMORY::free(this->m_begin + this->m_countAllocationOffset);
1655 this->m_begin =
nullptr;
1656 this->m_end =
nullptr;
1657 this->m_countAllocation = 0;
1658 this->m_countAllocationOffset = 0;
1665template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1666TYPE * array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_allocate_at(::collection::index i, ::collection::count c)
1669 auto newSize = this->size() + c;
1671 auto nMove = this->size() - i;
1673 this->allocate(newSize,
false,
true);
1675 ::safe_memory_transfer2(this->m_begin + i + c, (
size_t) (nMove), this->m_begin + i, (
size_t) (nMove));
1677 return this->m_begin + i;
1682template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1683TYPE & array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_at(::collection::index i,
const TYPE & element, ::collection::count c)
1686 auto p = this->raw_allocate_at(i, c);
1688 TYPED::copy_construct_count(p, c, element);
1695template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1696TYPE * array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_at(::collection::index i,
const TYPE * pelements, ::collection::count c)
1699 auto p = this->raw_allocate_at(i, c);
1701 TYPED::copy_construct_count(p, c, pelements);
1708template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1709TYPE * array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_array_at(::collection::index i,
const array_base_quantum * p)
1712 return this->insert_at(i, p->m_begin, p->size());
1767template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1768template <
typename CONTAINER >
1769::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append_container(
const CONTAINER & container)
1772 ::collection::count nOldSize = this->size();
1774 for (
auto&
item : container)
1786template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1787::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append_initializer_list(const ::std::initializer_list < TYPE >&
list)
1790 return append_container(
list);
1795template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1796::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append(
const TYPE * p, ::collection::count c)
1799 ::collection::count nOldSize = this->size();
1801 ::collection::count nSrcSize = c;
1803 allocate(nOldSize + nSrcSize,
false,
true);
1805 TYPED::copy_construct_count((this->m_begin + nOldSize), nSrcSize, p);
1812template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1813::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append(
const array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & src)
1816 return append(src.data(), src.size());
1822template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1823template <
typename CONTAINER >
1824void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy_container(
const CONTAINER & container)
1829 append_initializer_list(container);
1834template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1835void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy_initializer_list(const ::std::initializer_list < TYPE >&
list)
1838 copy_container(
list);
1844template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1845void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy(
const TYPE * p, ::collection::count c)
1848 if(this->data() == p)
1851 if (c > this->size())
1854 throw_exception(error_wrong_state);
1857 else if (c < this->size())
1875template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1876void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::copy(
const array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >& src)
1879 copy(src.data(), src.size());
1902template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1903template < primitive_array ARRAY >
1904void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_indexes(
const ARRAY & ia)
1909 for(::collection::index i = ia.get_upper_bound(); i >= 0; i--)
1919template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1920template < primitive_array ARRAY >
1921void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_descending_indexes(
const ARRAY & ia)
1924 for(::collection::index i = 0; i < ia.get_count(); i++)
1996template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
1997TYPE array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pick_at(::collection::index nIndex)
2000 ::collection::count nCount = 1;
2002 ::collection::index nUpperBound = nIndex + nCount;
2004 if (nIndex < 0 || nCount < 0 || (nUpperBound > this->size()) || (nUpperBound < nIndex) || (nUpperBound < nCount))
2007 throw_exception(error_bad_argument);
2011 ::collection::count nMoveCount = this->size() - (nUpperBound);
2013 auto t = ::transfer(this->m_begin[nIndex]);
2020 ::safe_memory_transfer2(this->m_begin + nIndex, (
size_t)nMoveCount, this->m_begin + nUpperBound, (
size_t)nMoveCount);
2024 this->m_end -= nCount;
2026 return ::transfer(t);
2031template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2032array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pick_at(::collection::index nIndex, ::collection::count nCount)
2037 ::collection::index nUpperBound = nIndex + nCount;
2039 if (nIndex < 0 || nCount < 0 || (nUpperBound > this->size()) || (nUpperBound < nIndex) || (nUpperBound < nCount))
2042 throw_exception(error_bad_argument);
2046 ::collection::count nMoveCount = this->size() - (nUpperBound);
2048 array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > a(this->m_begin + nIndex, (
size_t)nMoveCount);
2050 TYPED::destruct_count(this->m_begin + nIndex, nCount);
2055 ::safe_memory_transfer2(this->m_begin + nIndex, (
size_t)nMoveCount, this->m_begin + nUpperBound, (
size_t)nMoveCount);
2059 this->m_end -= nCount;
2257template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2258void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::reserve(::collection::count newAllocationSize)
2261 if(newAllocationSize <= m_countAllocation)
2268 if(m_countAllocation <= 0)
2271 ASSERT(this->m_begin ==
nullptr && this->m_end ==
nullptr);
2273 if(newAllocationSize > UPTR_MAXIMUM /
sizeof(TYPE))
2276 throw_exception(error_no_memory);
2280 newAllocationSize = maximum(newAllocationSize, m_countAddUp);
2282#if MEMDLEAK || defined(__MCRTDBG)
2284 if(::get_task() !=
nullptr)
2287#if defined(__MCRTDBG)
2289 if(::get_task()->m_strFile.has_character())
2292 this->m_begin = MEMORY::allocate(newAllocationSize, ::get_task()->m_strFile, ::get_task()->m_iLine);
2298 this->m_begin = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2304 if (::get_task_object_debug().has_character())
2307 this->m_begin = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
2313 this->m_begin = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
2323 this->m_begin = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2329 this->m_begin = MEMORY::allocate(newAllocationSize, &newAllocationSize);
2333 this->m_end = this->m_begin;
2339 auto countOld = this->size();
2341 auto countAddUp = m_countAddUp;
2346 countAddUp = this->size();
2348 constrain(countAddUp, 4, 1024);
2352 if(newAllocationSize < m_countAllocation + countAddUp)
2355 newAllocationSize = m_countAllocation + countAddUp;
2359 if(newAllocationSize > UPTR_MAXIMUM /
sizeof(TYPE))
2362 throw_exception(error_no_memory);
2366#if MEMDLEAK || defined(__MCRTDBG)
2368 TYPE* pNewData =
nullptr;
2370 if(::get_task() !=
nullptr)
2373#if defined(__MCRTDBG)
2375 if(::get_task()->m_strFile.has_character())
2378 pNewData = MEMORY::allocate(newAllocationSize, ::get_task()->m_strFile,::get_task()->m_iLine);
2384 pNewData = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2390 if (::get_task_object_debug().has_character())
2393 pNewData = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
2399 pNewData = MEMORY::allocate(newAllocationSize,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
2409 pNewData = MEMORY::allocate(newAllocationSize, __FILE__, __LINE__);
2415 TYPE * pNewData = MEMORY::allocate(newAllocationSize, &newAllocationSize);
2420 ::safe_memory_copy2(pNewData, (
size_t)newAllocationSize, this->m_begin, (
size_t) this->size());
2423 MEMORY::free(this->m_begin);
2425 this->m_begin = pNewData;
2427 this->m_end = this->m_begin + countOld;
2431 m_countAllocation = newAllocationSize;
2436template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
2437::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::_allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw,
const TYPE * ptype)
2440 ASSERT(nNewSize >= 0);
2445 throw_exception(error_bad_argument);
2449 ::collection::count countOld = get_count();
2451 if(nNewSize == countOld)
2461 if(this->m_begin !=
nullptr)
2464 TYPED::destruct_count(this->m_begin, this->size());
2469 MEMORY::free(this->m_begin + this->m_countAllocationOffset);
2471 this->m_countAllocationOffset = 0;
2473 this->m_begin =
nullptr;
2475 m_countAllocation = 0;
2481 this->m_end = this->m_begin;
2484 else if(this->m_begin ==
nullptr)
2487 if(nNewSize > UPTR_MAXIMUM /
sizeof(TYPE))
2490 throw_exception(error_no_memory);
2494 auto nAllocSize = maximum(nNewSize, m_countAddUp);
2496#if MEMDLEAK || defined(__MCRTDBG)
2498 if(::get_task() !=
nullptr)
2501#if defined(__MCRTDBG)
2503 if(::get_task()->m_strFile.has_character())
2506 this->m_begin = MEMORY::allocate(nAllocSize, ::get_task()->m_strFile, ::get_task()->m_iLine);
2512 this->m_begin = MEMORY::allocate(nAllocSize, __FILE__, __LINE__);
2518 if (::get_task_object_debug().has_character())
2521 this->m_begin = MEMORY::allocate(nAllocSize,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
2527 this->m_begin = MEMORY::allocate(nAllocSize,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
2537 this->m_begin = MEMORY::allocate(nAllocSize, __FILE__, __LINE__);
2543 this->m_begin = MEMORY::allocate(nAllocSize, &nAllocSize);
2550 if (::is_null(ptype))
2553 TYPED::construct_count(this->m_begin, nNewSize);
2559 TYPED::copy_construct_count(this->m_begin, nNewSize, *ptype);
2565 this->m_end = this->m_begin + nNewSize;
2567 m_countAllocation = nAllocSize;
2570 else if(nNewSize <= m_countAllocation)
2573 defer_erase_allocation_offset();
2578 if (nNewSize > countOld)
2581 if (::is_null(ptype))
2584 TYPED::construct_count(this->m_begin + countOld, nNewSize - countOld);
2590 TYPED::copy_construct_count(this->m_begin + countOld, nNewSize - countOld, *ptype);
2595 else if (countOld > nNewSize)
2598 TYPED::destruct_count(this->m_begin + nNewSize, countOld - nNewSize);
2604 this->m_end = this->m_begin + nNewSize;
2610 auto countAddUp = m_countAddUp;
2615 countAddUp = this->size();
2617 constrain(countAddUp, 4, 1024);
2621 ::collection::count countNewAllocation;
2623 if(nNewSize < m_countAllocation + countAddUp)
2626 countNewAllocation = m_countAllocation + countAddUp;
2632 countNewAllocation = nNewSize;
2636 if(countNewAllocation > UPTR_MAXIMUM /
sizeof(TYPE))
2639 throw_exception(error_no_memory);
2643#if MEMDLEAK || defined(__MCRTDBG)
2645 TYPE* pNewData =
nullptr;
2647 if(::get_task() !=
nullptr)
2650#if defined(__MCRTDBG)
2652 if(::get_task()->m_strFile.has_character())
2655 pNewData = MEMORY::allocate(countNewAllocation, ::get_task()->m_strFile,::get_task()->m_iLine);
2661 pNewData = MEMORY::allocate(countNewAllocation, __FILE__, __LINE__);
2667 if (::get_task_object_debug().has_character())
2670 pNewData = MEMORY::allocate(countNewAllocation,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
2676 pNewData = MEMORY::allocate(countNewAllocation,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
2686 pNewData = MEMORY::allocate(countNewAllocation, __FILE__, __LINE__);
2693 TYPE * pNewData = MEMORY::allocate(countNewAllocation, &countNewAllocation);
2698 ::safe_memory_copy2(pNewData, (
size_t)countNewAllocation, this->m_begin, (
size_t) countOld);
2704 ASSERT(nNewSize > countOld);
2706 if (nNewSize > countOld)
2709 if (::is_null(ptype))
2712 TYPED::construct_count(pNewData + countOld, nNewSize - countOld);
2718 TYPED::copy_construct_count(pNewData + countOld, nNewSize - countOld, *ptype);
2727 MEMORY::free(this->m_begin + this->m_countAllocationOffset);
2729 this->m_begin = pNewData;
2731 this->m_end = this->m_begin + nNewSize;
2733 this->m_countAllocationOffset = 0;
2735 m_countAllocation = countNewAllocation;
3032template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3033void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::on_after_read()
3043template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3044inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::set_at_grow(::collection::index nIndex, ARG_TYPE newElement)
3047 ASSERT(nIndex >= 0);
3049 if (nIndex >= this->size())
3052 this->set_size(nIndex + 1);
3056 this->m_begin[nIndex] = newElement;
3061template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3062inline TYPE & array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::element_at_grow(::collection::index nIndex)
3065 ASSERT(nIndex >= 0);
3067 if (nIndex >= this->size())
3070 this->set_size(nIndex + 1);
3074 return this->m_begin[nIndex];
3079template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3080inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::set_each(ARG_TYPE element, ::collection::index first, ::collection::count in_count_out_last)
3083 prepare_first_in_count_last_out(first, in_count_out_last);
3085 for(::collection::index i = first; i <= in_count_out_last; i++)
3088 this->m_begin[i] = element;
3095template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3096template <
typename ITERATOR2 >
3097inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase(
const ITERATOR2 & begin,
const ITERATOR2 & last)
3100 auto start = this->index_of(begin);
3102 auto end = this->index_of(last);
3104 if(start < 0 || (end <= start && end >= 0))
3111 auto count = end > start ? end - start : -1;
3113 erase_at(start, count);
3119template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3120bool array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::prepare_first_last(::collection::index & first, ::collection::index & last)
const
3126 first += this->get_count();
3133 last += this->get_count();
3137 return last >= first;
3142template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3143bool array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::prepare_first_in_count_last_out(::collection::index & first, ::collection::count & in_count_out_last)
const
3149 first += this->get_count();
3160 if (in_count_out_last < 0)
3163 in_count_out_last += this->get_count();
3169 in_count_out_last = first + in_count_out_last - 1;
3173 return in_count_out_last >= first;
3185template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3186inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_size()
const
3188 return (::collection::count) this->size();
3192template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3193inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_count()
const
3195 return (::collection::count) this->size();
3199template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3200inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_length()
const
3202 return (::collection::count) this->size();
3206template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3207inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_size_in_bytes()
const
3209 return (::collection::count)this->size() *
sizeof(TYPE);
3213template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3214inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_byte_count()
const
3216 return (::collection::count) (this->size() *
sizeof(TYPE));
3227template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3228inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::count()
const
3230 return this->get_count();
3233template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3234inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::length()
const
3236 return this->get_length();
3263template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3264inline ::collection::index array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_lower_bound(::collection::index i)
const
3266 return i < this->size() ? i : -1;
3269template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3270inline ::collection::index array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_middle_index(::collection::index iIndex)
const
3272 return this->size() / 2 + iIndex;
3276template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3277inline ::collection::index array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::get_upper_bound(::collection::index iIndex)
const
3279 return this->size() + iIndex;
3282template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3283inline bool array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::bounds(::collection::index i)
const
3285 return i >= 0 && i < this->size();
3289template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3290inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase_all()
3293 return allocate(0,
false,
false);
3298template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3299inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::set_size(::collection::index nNewSize)
3302 return allocate(nNewSize,
false,
false);
3307template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3308inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::clear()
3316template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3317inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase_first(::collection::count c)
3320 ASSERT(this->size() >= c);
3327template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3328inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase_last(::collection::count c)
3331 ASSERT(this->size() >= c);
3333 erase_at(get_upper_bound(-c), c);
3338template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3339inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::zero(::collection::index iStart,::collection::count c)
3343 c = get_size() - iStart;
3345 ::zero(&this->m_begin[iStart],c *
sizeof(TYPE));
3349template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3350inline const TYPE& array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::element_at(::collection::index nIndex)
const
3353 ASSERT(nIndex >= 0 && nIndex < this->size());
3355 return this->m_begin[nIndex];
3360template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3361inline TYPE& array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::element_at(::collection::index nIndex)
3364 ASSERT(nIndex >= 0 && nIndex < this->size());
3366 return this->m_begin[nIndex];
3426template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3427inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::__swap(::collection::index index1, ::collection::index index2)
3430 ::__swap(this->m_begin[index1], this->m_begin[index2]);
3435template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3436inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::__swap(
iterator it1,
iterator it2)
3449template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3450inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::__swap(const_iterator it1, const_iterator it2)
3453 auto t = (TYPE) *it1;
3455 ((TYPE &)*it1) = (
const TYPE &) *it2;
3462template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3463inline const TYPE& array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::first(::collection::index nIndex)
const
3466 return this->element_at(nIndex);
3471template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3472inline TYPE & array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::first(::collection::index nIndex)
3475 return this->element_at(nIndex);
3480template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3481inline const TYPE & array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::last(::collection::index i)
const
3484 return element_at(this->get_upper_bound(i));
3489template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3490inline TYPE & array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::last(::collection::index i)
3493 return element_at(this->get_upper_bound(i));
3498template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3499inline const TYPE & array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::middle(::collection::index i)
const
3502 return element_at(this->get_middle_index(i));
3507template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3508inline TYPE & array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::middle(::collection::index i)
3511 return element_at(this->get_middle_index(i));
3516template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3517void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::set_all(
const TYPE & t)
3520 for (::collection::index i = 0; i < get_count(); i++)
3523 this->m_begin[i] = t;
3556template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3557inline TYPE array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop(::collection::index n)
3560 ::collection::index i = this->get_upper_bound(n);
3562 TYPE t = element_at(i);
3570template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3571inline TYPE array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop_first(::collection::index i)
3574 auto t = ::transfer(this->first(i));
3583template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3584inline void array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop_back(::collection::index n)
3587 erase_at(this->get_upper_bound(n));
3592template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3593inline ::collection::index array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::push(ARG_TYPE newElement)
3596 return index_of(&insert_at(this->size(), newElement));
3601template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3602inline TYPE& array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add_item(ARG_TYPE newElement)
3605 auto nIndex = this->size();
3607 this->allocate(nIndex + 1,
false,
false, newElement);
3609 return this->element_at(nIndex);
3614template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3615TYPE& array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add_new()
3618 auto nIndex = this->size();
3620 this->allocate(nIndex + 1,
false,
false);
3622 return this->last();
3636template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3637inline TYPE array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::takeAt(::collection::index i)
3640 TYPE t = element_at(i);
3649template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3650inline TYPE array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::takeFirst(::collection::index i)
3653 TYPE t = element_at(i);
3662template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3663inline TYPE array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::takeLast(::collection::index n)
3666 ::collection::index i = this->get_upper_bound(n);
3668 TYPE t = element_at(i);
3677template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3678array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::array_base_quantum(
const TYPE * p, ::collection::count c)
3682 this->m_begin =
nullptr;
3683 this->m_end =
nullptr;
3684 m_countAllocation = 0;
3688 for (::collection::index i = 0; i < c; i++)
3691 element_at(i) = p[i];
3701template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
3702inline ::collection::count array_base_quantum < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > ::erase(
const TYPE * begin,
const TYPE * last)
3705 auto iStart = index_of(begin);
3707 auto iEnd = index_of(last);
3710 return erase_at(iStart, iEnd - iStart);
Definition array_base_quantum.h:179
::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 array_base_quantum.h:741
Definition array_base_quantum.h:70
Definition _forward_declaration.h:1237
Definition std_iterator.h:49