15class pointer_array_base :
16 public ø < pointer_array_process < comparable_array_base < ::pointer < T >, ARG_T, comparable_eq_array_base < ::pointer < T >, ARG_T, ARRAY_BASE > > , T > >
20 using BASE_ARRAY = ø < pointer_array_process < comparable_array_base < ::pointer < T >, ARG_T, comparable_eq_array_base < ::pointer < T >, ARG_T, ARRAY_BASE > > , T > >;
32 using BASE_ARRAY::BASE_ARRAY;
33 using BASE_ARRAY::operator =;
60 template <
typename OTHER >
61 pointer_array_base(
const pointer_array_base < OTHER > & a)
67 pointer < T > pNew = p;
94 pointer < T >& add_new()
97 return BASE_ARRAY::add_new();
102 template <
typename OBJECT >
103 pointer < T > & add_construct(OBJECT * pparticle)
106 pointer < T > & p = BASE_ARRAY::add_new();
108 pparticle->constructø(p);
115 template <
typename... Args >
116 pointer<T> & main_add(Args... args)
119 auto pNew = allocateø T (args...);
121 auto iIndex = this->
add(pNew);
123 return this->element_at(iIndex);
129 ::collection::count set_size(::collection::count nNewSize, ::collection::count nGrowBy = -1)
132 return BASE_ARRAY :: set_size(nNewSize);
136 template <
typename OBJECT >
137 ::collection::count set_size_create(OBJECT * pparticle, ::collection::count nNewSize, ::collection::count nGrowBy = -1);
140 template <
class DERIVED >
141 ::pointer<DERIVED>get(::collection::index iStart = 0)
144 ::pointer<DERIVED>pderived;
146 for(::collection::index i = iStart; i < this->get_count(); i++)
152 pderived = this->element_at(i);
160 if (pderived.is_set())
174 template <
class DERIVED >
175 ::pointer<DERIVED>typed_ptr_at(::collection::index iIndex)
178 return this->element_at(iIndex);
184 inline ::collection::index
add_item(
const pointer < T > & p)
187 ::collection::index nIndex = this->size();
189 this->allocate(nIndex + 1,
false,
false, p);
197 inline ::collection::index
add_item(pointer < T > && p)
200 ::collection::index nIndex = this->size();
202 this->allocate(nIndex + 1,
false,
false, p);
208 template < prototype_container CONTAINER >
209 ::collection::index append(
const CONTAINER & a)
212 return BASE_ARRAY::append(a);
226 ::collection::index
add(
const pointer < T > & p)
235 ::collection::index
add(pointer < T > && p)
238 return this->
add_item(::transfer(p));
265 BASE_ARRAY::insert_at(i, p);
272 bool insert_unique_at(::collection::index i, T * p);
276 template <
typename T2 >
287 auto p =
dynamic_cast <T*
> ((T2*)p2);
311 template <
typename T2 >
320 template <
typename T2 >
321 ::collection::count
add_unique(
const pointer_array_base < T2 > & a)
324 ::collection::count c = 0;
343 template <
typename TYPE >
344 ::pointer<TYPE>find_first()
const
347 for (
auto & pointer : this->ptra())
350 ::pointer<TYPE> ptype = pointer;
365 template <
typename TYPE >
366 bool contains()
const
369 return find_first < TYPE >();
374 template <
typename TYPE >
378 return contains < TYPE >();
383 bool contains(
const T * p, ::collection::index iStart = 0, ::collection::count nCount = -1)
const
386 return find_first(p, iStart, nCount) >= 0;
391 ::collection::index find_first(
const T * p, ::collection::index iStart = 0, ::collection::count inCountLastOut = -1)
const
394 this->prepare_first_in_count_last_out(iStart, inCountLastOut);
396 for(::collection::index i = iStart; i <= inCountLastOut; i++)
399 auto& pointer = this->element_at(i);
401 if (pointer && pointer.m_p == p)
415 void call_member(enum_id eid, ::collection::index iStart = 0, ::collection::count inCountLastOut = -1)
418 this->prepare_first_in_count_last_out(iStart, inCountLastOut);
424 for (::collection::index i = iStart; i <= inCountLastOut; i++)
427 auto p = this->element_at(i);
440 ::collection::index comp_find_first(
const T & t, ::collection::index (* pfnCompare)(
const T *,
const T *), ::collection::index iStart = 0, ::collection::count nCount = -1)
const
443 return this->comp_find_first(&t, pfnCompare, iStart, nCount);
448 ::collection::index comp_find_first(
const T * p, ::collection::index (* pfnCompare)(
const T *,
const T *), ::collection::index iStart = 0, ::collection::count inCountLastOut = -1)
const
451 this->prepare_first_in_count_last_out(iStart, inCountLastOut);
453 for(::collection::index i = iStart; i <= inCountLastOut; i++)
456 if (pfnCompare(this->element_at(i).m_p, p) == 0)
485 return this->erase_item(p);
490 ::collection::count erase_item(T * p)
493 ::collection::count ca = 0;
495 ::collection::index iFind = 0;
497 while((iFind = this->find_first(p, iFind)) >= 0)
502 this->erase_at(iFind);
515 template <
typename TYPE >
516 ::collection::count erase_type(TYPE *)
519 ::collection::count c = 0;
521 for (::collection::index i = this->get_upper_bound(); i >= 0; i--)
524 if (
typeid(*this->element_at(i).m_p) == ::type<TYPE>())
541 template <
typename PRED >
542 ::collection::index predicate_erase_first(PRED pred, ::collection::index iStart = 0)
545 for (::collection::index i = iStart; i < this->get_count(); i++)
548 if (pred(this->m_begin[i]))
564 template <
typename PRED >
565 ::collection::index predicate_erase_last(PRED pred, ::collection::index iStart = 0)
568 for (::collection::index i = this->get_upper_bound(); i >= 0; i--)
571 if (pred(this->m_begin[i]))
586 template <
typename PRED >
587 pointer < T > predicate_erase_all_get_first(PRED pred, ::collection::index iStart = 0, ::collection::index iEnd = -1)
595 iEnd += this->get_count();
599 if (iEnd >= this->get_count())
602 iEnd = this->get_count() - 1;
607 for (::collection::index i = iStart; i <= iEnd;)
610 if (pred(this->m_pData[i]))
616 sp = this->m_pData[i];
638 pointer < T > sp_at(::collection::index nIndex)
const
641 if (nIndex < 0 || nIndex >= this->size())
648 return this->BASE_ARRAY ::element_at(nIndex);
653 pointer < T > & sp_at(::collection::index nIndex)
663 return this->BASE_ARRAY ::element_at(nIndex);
668 T * ptr_at(::collection::index nIndex)
const
671 if (nIndex < 0 || nIndex >= this->size())
678 return this->BASE_ARRAY ::element_at(nIndex).m_p;
683 T * ptr_at(::collection::index nIndex)
686 return this->sp_at(nIndex);
691 T & at(::collection::index nIndex)
const
694 return *this->ptr_at(nIndex);
699 T & at(::collection::index nIndex)
702 return *this->ptr_at(nIndex);
706 T * get_first_pointer(::collection::index n = 0)
const
709 return this->is_empty() ? nullptr : this->comparable_array_base < ::pointer<T >,
const T *> ::first(n);
714 pointer < T > pop_first(::collection::index n = 0)
717 auto p = ::transfer(this->BASE_ARRAY ::first(n));
719 this->BASE_ARRAY ::erase_at(n);
726 pointer < T > & first_pointer(::collection::index n = 0)
729 return this->BASE_ARRAY ::first(n);
734 T * first_ptr(::collection::index n = 0)
const
737 if (this->is_empty())
744 return this->get_first_pointer(n);
749 T * first_ptr(::collection::index n = 0)
752 return this->first_pointer(n);
757 T * get_last_pointer(::collection::index n = -1)
const
760 return this->is_empty() ? nullptr : this->BASE_ARRAY ::last(n);
765 pointer < T > & last_pointer(::collection::index n = -1)
768 return this->BASE_ARRAY ::last(n);
773 T * last_ptr(::collection::index n = -1)
const
776 return this->get_last_pointer(n);
781 T * last_ptr(::collection::index n = -1)
784 return this->last_pointer(n);
789 const T & operator() (::collection::index nIndex)
const
792 return *this->sp_at(nIndex);
797 T & operator() (::collection::index nIndex)
800 return *this->sp_at(nIndex);
806 template <
typename PRED >
807 T * predicate_ptr_first(PRED pred)
810 ::collection::index i = this->predicate_find_first(pred);
815 return this->ptr_at(i);
836 template < prototype_container ARRAY >
837 ::collection::count
add(const ::pointer<ARRAY>& pa)
840 ::collection::count c = pa->get_count();
842 for(::collection::index i = 0; i < c; i++)
844 this->
add(pa->element_at(i));
851 template < prototype_container ARRAY >
852 ::collection::count
add(
const ARRAY & a)
855 ::collection::count c = a.get_count();
857 for(::collection::index i = 0; i < c; i++)
859 this->
add(a.element_at(i));
867 ::collection::count append(
const pointer_array_base & a)
870 ::collection::count c = a.get_count();
872 for(::collection::index i = 0; i < c; i++)
875 this->
add(a.sp_at(i));
884 template < prototype_container ARRAY >
885 ::collection::count append_ptra(
const ARRAY* pptra)
888 ::collection::count c = pptra->get_count();
890 for(::collection::index i = 0; i < c; i++)
892 this->
add(*pptra->element_at(i));
914 template <
class ARRAY >
915 pointer_array_base & copy(const ::pointer<ARRAY>& pa)
918 if(pa ==
dynamic_cast < ARRAY *
> (
this))
930 ::collection::count erase_all()
935 for (::collection::index i = 0; i < this->get_size(); i++)
941 auto & p = this->element_at(i);
958 return BASE_ARRAY ::erase_all();
974 pointer_array_base & copy(
const pointer_array_base & a)
988 template <
class ARRAY >
989 pointer_array_base & copy_ptra(
const ARRAY * pptra)
992 if(pptra ==
dynamic_cast < ARRAY *
> (
this))