4#include "acme/prototype/collection/array_base.h"
12template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
14 public array_base < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >
19 using BASE_TYPE = TYPE;
20 using BASE_ARG_TYPE = ARG_TYPE;
21 using BASE_ARRAY = array_base < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >;
22 using ARRAY_BASE = base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >;
23 using BASE_RAW_RANGE =
typename BASE_ARRAY::BASE_RAW_RANGE;
24 using iterator =
typename ARRAY_BASE::iterator;
25 using const_iterator =
typename ARRAY_BASE::const_iterator;
28 using BASE_ARRAY::BASE_ARRAY;
29 using BASE_ARRAY::operator =;
50 ::collection::count erase_all();
57 inline const TYPE& get_at(::collection::index nIndex)
const;
58 inline TYPE& get_at(::collection::index nIndex);
59 inline void set_at(::collection::index nIndex, ARG_TYPE newElement);
63 inline const TYPE* get_data()
const;
64 inline TYPE* get_data();
69 TYPE get_at_grow(::collection::index nIndex);
70 ::collection::index add(ARG_TYPE newElement) {
return add_item(newElement); }
71 ::collection::index add_item(ARG_TYPE newElement);
72 ::collection::index append(
const TYPE * p, ::collection::count c);
74 TYPE * add_new(::collection::count count);
81 inline TYPE pop(::collection::index i = -1);
82 inline ::collection::index push(ARG_TYPE newElement);
83 inline void pop_back(::collection::index i = -1);
105 TYPE & insert_at(::collection::index nIndex, ARG_TYPE newElement, ::collection::count nCount = 1);
115 ::collection::index find_first(ARG_TYPE t, ::collection::index (* pfnCompare)(ARG_TYPE, ARG_TYPE), ::collection::index start = 0, ::collection::index last = -1)
const;
117 ::collection::index raw_find_first(TYPE * p, ::collection::index first = 0, ::collection::index last = -1)
const;
119 template <
class DERIVED >
120 ::collection::index find_first(DERIVED * p, ::collection::index first = 0, ::collection::index last = -1)
122 return raw_find_first(
dynamic_cast < TYPE *
> (p), first, last);
125 template <
class ARRAY >
126 ::collection::count get_array(ARRAY & a, ::collection::index iStart = 0, ::collection::count nCount = -1)
129 ::collection::count ca = 0;
131 ::collection::index iEnd;
134 iEnd = this->get_upper_bound(nCount);
136 iEnd = iStart + nCount - 1;
138 for(::collection::index i = iStart; i <= iEnd; i++)
141 a.add(this->element_at(i));
165 operator ::collection::count ()
const {
return this->get_count(); }
191template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
192inline ::collection::count raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_all()
195 return this->allocate(0,
false,
false);
200template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
201void raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::clear()
209template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
210inline void raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::erase_last()
213 this->erase_at(this->get_upper_bound());
218template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
219inline TYPE& raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::get_at(::collection::index nIndex)
222 return get_data()[nIndex];
227template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
228inline const TYPE& raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::get_at(::collection::index nIndex)
const
231 return get_data()[nIndex];
236template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
237inline void raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::set_at(::collection::index nIndex, ARG_TYPE newElement)
240 get_data()[nIndex] = newElement;
245template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
246inline const TYPE* raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::get_data()
const
249 return (
const TYPE*)this->m_begin;
254template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
255inline TYPE* raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::get_data()
258 return (TYPE*)this->m_begin;
263template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
264inline ::collection::index raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::add_item(ARG_TYPE newElement)
267 ::collection::index nIndex = this->size();
269 this->set_at_grow(nIndex, newElement);
276template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
277inline ::collection::index raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::append(
const TYPE * p, ::collection::count c)
280 return ARRAY_BASE::append(p, c);
285template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
286inline ::collection::index raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::append(
const raw_array_base & src)
289 return ARRAY_BASE::append(src);
294template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
295inline TYPE * raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::add_new(::collection::count count)
298 this->allocate(this->size() + count,
false,
true);
300 return this->m_begin + (this->get_size() - count);
305template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
306inline TYPE & raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::add_new()
309 this->allocate(this->size() + 1,
false,
true);
316template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
317inline TYPE raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::pop(::collection::index n)
320 ::collection::index i = this->get_upper_bound(n);
322 TYPE t = this->element_at(i);
330template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
331inline void raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::pop_back(::collection::index n)
334 this->erase_at(this->get_upper_bound(n));
339template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
340inline ::collection::index raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::push(ARG_TYPE newElement)
343 return this->index_of(&insert_at(this->size(), newElement));
654template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
655inline TYPE raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::get_at_grow(::collection::index nIndex)
658 return this->element_at_grow(nIndex);
672template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
673TYPE & raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::insert_at(::collection::index nIndex, ARG_TYPE newElement, ::collection::count nCount )
676 return base_array < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::insert_at(nIndex, newElement,nCount);
790template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
791::collection::index raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::raw_find_first(TYPE *p, ::collection::index find, ::collection::index last)
const
795 find += this->get_count();
798 last += this->get_count();
800 for(; find <= last; find++)
803 if (&this->element_at(find) == p)
817template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
818::collection::index raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::find_first(ARG_TYPE t, ::collection::index ( * pfnCompare )(ARG_TYPE, ARG_TYPE), ::collection::index find, ::collection::index last)
const
822 find += this->get_count();
824 last += this->get_count();
825 for(; find <= last; find++)
827 if(pfnCompare((ARG_TYPE)this->element_at(find), (ARG_TYPE)t) == 0)
837template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
838raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer > & raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::operator += (
const raw_array_base & a)
843 raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer > aCopy(a);
854template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
855raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer > raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer >::operator + (
const raw_array_base & a)
const
857 raw_array_base < TYPE, ARG_TYPE, TYPED, MEMORY,t_etypeContainer > aNew(*
this);
Definition raw_array.h:15