acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
aaa__raw_array_impl2.h
1#pragma once
2
3//
4// see collection_raw_array_decl.h for declaration
5//
6// raw_array is an array that does not call constructors or destructor in elements
7// array is an array that call only copy constructor and destructor in elements
8// array is an array that call default constructors, copy constructs and destructors in elements
9
10//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
11//inline ::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_size() const
12//{
13// return m_nSize;
14//}
15//
16//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
17//inline ::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_size_in_bytes() const
18//{
19// return m_nSize * sizeof(TYPE);
20//}
21//
22//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
23//inline ::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_count() const
24//{
25// return this->get_size();
26//}
27//
28//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
29//inline ::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_byte_count() const
30//{
31// return this->get_size_in_bytes();
32//}
33//
34//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
35//inline ::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::size() const
36//{
37// return this->get_size();
38//}
39//
40//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
41//inline ::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::collection::count() const
42//{
43// return this->get_count();
44//}
45//
46//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
47//inline bool raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::is_empty(::collection::count countMinimum) const
48//{
49// return m_nSize < countMinimum;
50//}
51//
52//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
53//inline bool raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::empty(::collection::count countMinimum) const
54//{
55// return m_nSize < countMinimum;
56//}
57//
58//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
59//inline bool raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::has_elements(::collection::count countMinimum) const
60//{
61// return m_nSize >= countMinimum;
62//}
63//
64//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
65//inline ::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_upper_bound(::collection::index i) const
66//{
67// return m_nSize + ::collection::index;
68//}
69//
70template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
71inline ::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_all()
72{
73 return this->allocate(0, -1);
74}
75
76template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
77void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::
78clear()
79{
80 erase_all();
81}
82
83
84template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
85inline void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase_last()
86{
87
88 this->erase_at(this->get_upper_bound());
89
90}
91
92
93template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
94inline TYPE& raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_at(::collection::index nIndex)
95{
96
97 return get_data()[nIndex];
98}
99
100
101template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
102inline const TYPE& raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_at(::collection::index nIndex) const
103{
104
105 return get_data()[nIndex];
106
107}
108
109
110template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
111inline void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::set_at(::collection::index nIndex, ARG_TYPE newElement)
112{
113
114 get_data()[nIndex] = newElement;
115
116}
117
118
119template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
120inline const TYPE* raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_data() const
121{
122
123 return (const TYPE*)this->m_pData;
124
125}
126
127
128template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
129inline TYPE* raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_data()
130{
131
132 return (TYPE*)this->m_pData;
133
134}
135
136
137template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
138inline ::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add(ARG_TYPE newElement)
139{
140
141 ::collection::index nIndex = (::index_cast ) this->m_nSize;
142
143 set_at_grow(nIndex, newElement);
144
145 return nIndex;
146
147}
148
149
150template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
151inline ::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add(const raw_array & src)
152{
153
154 return this->append(src);
155
156}
157
158
159template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
160inline ::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add_new(::collection::count count)
161{
162
163 this->allocate(this->size() + count);
164
165 return this->get_upper_bound();
166
167}
168
169
170template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
171inline TYPE & raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::add_new()
172{
173
174 this->allocate(this->size() + 1);
175
176 return this->last();
177
178}
179
180
181template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
182inline TYPE raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop(::collection::index n)
183{
184
185 ::collection::index i = this->get_upper_bound(n);
186
187 TYPE t = this->element_at(i);
188
189 this->erase_at(i);
190
191 return t;
192
193}
194
195template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
196inline void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::pop_back(::collection::index n)
197{
198
199 this->erase_at(this->get_upper_bound(n));
200
201}
202
203template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
204inline ::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::push(ARG_TYPE newElement, ::collection::index n)
205{
206 return insert_at(this->get_upper_bound(n), newElement);
207}
208
209template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
210inline void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::push_back(ARG_TYPE newElement, ::collection::index n)
211{
212 insert_at(this->get_upper_bound(n), newElement);
213}
214
215
216//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
217//inline const TYPE& raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::operator[](::collection::index nIndex) const
218//{
219//
220// return this->element_at(nIndex);
221//
222//}
223//
224//
225//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
226//inline TYPE& raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::operator[](::collection::index nIndex)
227//{
228//
229// return this->element_at(nIndex);
230//
231//}
232
233
234template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
235inline void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::__swap(::collection::index index1, ::collection::index index2)
236{
237 TYPE t = get_data()[index1];
238 get_data()[index1] = get_data()[index2];
239 get_data()[index2] = t;
240}
241
242template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
243inline raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::operator = (const raw_array & src)
244{
245 if(&src != this)
246 {
247 this->copy(src);
248 }
249 return *this;
250}
251
252
253
254// out-of-line functions
255
256template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
257raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_array(::particle * pparticle)
258 //:
259 //::matter(pparticle)
260{
261
262}
263
264
265template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
266inline raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_array(::std::initializer_list < TYPE > l)
267{
268 forallref(l)
269 {
270 add((ARG_TYPE) item);
271 }
272}
273
274
275
276template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
277raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_array(const raw_array <TYPE, ARG_TYPE, ALLOCATOR> & a)// :
278 // matter(a.get_app())
279{
280 ::base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::operator = (a);
281}
282
283template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
284raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_array(raw_array <TYPE,ARG_TYPE,ALLOCATOR> && a) //:
285// matter(a.get_app())
286{
287
288 this->m_nGrowBy = a.m_nGrowBy;
289 this->m_pData = a.m_pData;
290 this->m_nSize = a.m_nSize;
291 this->m_nMaxSize = a.m_nMaxSize;
292
293 //a.m_nGrowBy = 0;
294 a.m_pData = nullptr;
295 //a.m_nSize = 0;
296 //a.m_nMaxSize = 0;
297
298}
299
300
301template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
302raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >:: raw_array(::collection::count n)
303{
304 this->allocate(n);
305}
306
307template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
308raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_array(ARG_TYPE t, ::collection::count n)
309{
310 insert_at(0, t, n);
311}
312
313
314template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
315raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_array(TYPE * ptypea, ::collection::count n)
316{
317
318 this->allocate(n);
319
320 for(::i32 i = 0; i < n; i++)
321 {
322
323 this->element_at(i) = ptypea[i];
324
325 }
326
327}
328
329
330template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
331raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::~raw_array()
332{
333
334 this->destroy();
335
336}
337
338//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
339//void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::destroy()
340//{
341// if (m_pData != nullptr)
342// {
343// for( ::i32 i = 0; i < m_nSize; i++ )
344// destruct_element(m_pData + i)->~TYPE();
345// delete[] (::u8*)m_pData;
346// m_pData = nullptr;
347// m_nSize = 0;
348// m_nMaxSize = 0;
349// }
350//
351//}
352
353
354//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
355//::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::set_size(::collection::count nNewSize, ::collection::count nGrowBy)
356//{
357// return allocate(nNewSize, nGrowBy);
358//}
359//
360//
361//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
362//::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::resize(::collection::count nNewSize, ::collection::count nGrowBy)
363//{
364// return allocate(nNewSize, nGrowBy);
365//}
366//
367//
368//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
369//::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::allocate_in_bytes(::collection::count nNewSize, ::collection::count nGrowBy)
370//{
371// if(nGrowBy < 0)
372// {
373// return allocate(nNewSize / sizeof(TYPE), -1);
374// }
375// else
376// {
377// return allocate(nNewSize / sizeof(TYPE), nGrowBy / sizeof(TYPE));
378// }
379//}
380
381//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
382//::collection::count raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::allocate(::collection::count nNewSize, ::collection::count nGrowBy)
383//{
384// ::collection::count countOld = get_count();
385// ASSERT_OK(this);
386// ASSERT(nNewSize >= 0);
387//
388// if(nNewSize < 0 )
389// throw ::exception(error_bad_argument);
390//
391// if (nGrowBy >= 0)
392// m_nGrowBy = nGrowBy; // set aaa_primitive_new i32_size
393//
394// if (nNewSize == 0)
395// {
396// // shrink to nothing
397// if (m_pData != nullptr)
398// {
401// delete[] (::u8*)m_pData;
402// m_pData = nullptr;
403// }
404// m_nSize = m_nMaxSize = 0;
405// }
406// else if (m_pData == nullptr)
407// {
408// // create buffer big enough to hold number of requested elements or
409// // m_nGrowBy elements, whichever is larger.
410//#ifdef SIZE_T_MAX
411// if(nNewSize > SIZE_T_MAX/sizeof(TYPE))
412// throw ::exception(error_no_memory);
413// ASSERT(nNewSize <= SIZE_T_MAX/sizeof(TYPE)); // no overflow
414//#endif
415// ::collection::count nAllocSize = maximum(nNewSize, m_nGrowBy);
417// m_pData = (TYPE*) aaa_primitive_new ::u8[(size_t)nAllocSize * sizeof(TYPE)];
418// //memory_set((void *)m_pData, 0, (size_t)nAllocSize * sizeof(TYPE));
420// // ::aaa_primitive_new( (void *)( m_pData + i ) ) TYPE;
422// m_nSize = nNewSize;
423// m_nMaxSize = nAllocSize;
424// }
425// else if (nNewSize <= m_nMaxSize)
426// {
427// // it fits
428// if (nNewSize > m_nSize)
429// {
430// // initialize the aaa_primitive_new elements
436// }
437// else if (m_nSize > nNewSize)
438// {
439// // destroy the old elements
441// // (m_pData + nNewSize + i)->~TYPE();
442// }
443// m_nSize = nNewSize;
444// }
445// else
446// {
447// // otherwise, grow aaa_base_array
448// nGrowBy = m_nGrowBy;
449// if (nGrowBy == 0)
450// {
451// // heuristically determine growth when nGrowBy == 0
452// // (this avoids heap fragmentation in many situations)
453// nGrowBy = m_nSize / 8;
454// nGrowBy = (nGrowBy < 4) ? 4 : ((nGrowBy > 1024) ? 1024 : nGrowBy);
455// }
456// ::collection::count nNewMax;
457// if (nNewSize < m_nMaxSize + nGrowBy)
458// nNewMax = m_nMaxSize + nGrowBy; // granularity
459// else
460// nNewMax = nNewSize; // no slush
461//
462// ASSERT(nNewMax >= m_nMaxSize); // no wrap around
463//
464// if(nNewMax < m_nMaxSize)
465// throw ::exception(error_bad_argument);
466//
467//#ifdef SIZE_T_MAX
468// ASSERT(nNewMax <= SIZE_T_MAX/sizeof(TYPE)); // no overflow
469//#endif
470//
471// TYPE* pNewData = (TYPE*) aaa_primitive_new ::u8[(size_t)nNewMax * sizeof(TYPE)];
472//
473//
474// // copy aaa_primitive_new data from old
475// ::safe_memory_copy(pNewData, (size_t)nNewMax * sizeof(TYPE),
476// m_pData, (size_t)m_nSize * sizeof(TYPE));
477//
478// // construct remaining elements
479// ASSERT(nNewSize > m_nSize);
485// // get rid of old stuff (note: no destructors called)
486// delete[] (::u8*)m_pData;
487// m_pData = pNewData;
488// m_nSize = nNewSize;
489// m_nMaxSize = nNewMax;
490// }
491// return countOld;
492//}
493//
494
495//
496//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
497//void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::free_extra()
498//{
499// ASSERT_OK(this);
500//
501// if (m_nSize != m_nMaxSize)
502// {
503// // shrink to desired i32_size
504//#ifdef SIZE_T_MAX
505// ASSERT(m_nSize <= SIZE_T_MAX/sizeof(TYPE)); // no overflow
506//#endif
507// TYPE* pNewData = nullptr;
508// if (m_nSize != 0)
509// {
510// pNewData = (TYPE*) aaa_primitive_new ::u8[m_nSize * sizeof(TYPE)];
511// // copy aaa_primitive_new data from old
512// ::safe_memory_copy(pNewData, m_nSize * sizeof(TYPE),
513// m_pData, m_nSize * sizeof(TYPE));
514// }
515//
516// // get rid of old stuff (note: no destructors called)
517// delete[] (::u8*)m_pData;
518// m_pData = pNewData;
519// m_nMaxSize = m_nSize;
520// }
521//}
522
523//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
524//void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::set_at_grow(::collection::index nIndex, ARG_TYPE newElement)
525//{
526// //ASSERT_OK(this);
527// //ASSERT(nIndex >= 0);
528//
529// if(nIndex < 0)
530// throw ::exception(error_bad_argument);
531//
532// if (nIndex >= this->m_nSize)
533// this->allocate(nIndex+1, -1);
534// get_data()[nIndex] = newElement;
535//}
536
537template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
538inline TYPE raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::get_at_grow(::collection::index nIndex)
539{
540 return element_at_grow(nIndex);
541}
542
543
544//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
545//inline TYPE & raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::element_at_grow(::collection::index nIndex)
546//{
547// if (nIndex >= this->m_nSize)
548// this->allocate(nIndex+1, -1);
549// return get_data()[nIndex];
550//}
551
552
553template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
554::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_at(::collection::index nIndex, ARG_TYPE newElement, ::collection::count nCount /*=1*/)
555{
556
557 return base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_at(nIndex, newElement,nCount);
558
559}
560
561
562//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
563//::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::insert_at(::collection::index nStartIndex, raw_array * pNewArray)
564//{
565// ASSERT_OK(this);
566// ASSERT(pNewArray != nullptr);
567// ASSERT_OK(pNewArray);
568// ASSERT(nStartIndex >= 0);
569//
570// if(pNewArray == nullptr || nStartIndex < 0)
571// throw ::exception(error_bad_argument);
572//
573// if (pNewArray->get_size() > 0)
574// {
575// insert_at(nStartIndex, pNewArray->element_at(0), pNewArray->get_size());
576// for (::collection::index i = 1; i < pNewArray->get_size(); i++)
577// insert_at(nStartIndex + i, pNewArray->element_at(i));
578// }
579//
580// return nStartIndex;
581//
582//}
583
584
585//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
586//void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::dump(dump_context & dumpcontext) const
587//{
588//
589// matter::dump(dumpcontext);
590//
591// dumpcontext << "with " << this->m_nSize << " elements";
592//
593// if (dumpcontext.GetDepth() > 0)
594// {
595//
596// dumpcontext << "\n";
597//
598// dump_elements<TYPE>(dumpcontext,get_data(), this->m_nSize);
599//
600// }
601//
602// dumpcontext << "\n";
603//
604//}
605
606
607//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
608//void raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::assert_ok() const
609//{
610//
611// matter::assert_ok();
612//
613//
614// if (get_data() == nullptr)
615// {
616//
617// ASSERT(this->m_nSize == 0);
618// ASSERT(this->m_nMaxSize >= 0);
619//
620// }
621// else
622// {
623//
624// ASSERT(this->m_nSize >= 0);
625// ASSERT(this->m_nMaxSize >= 0);
626// ASSERT(this->m_nSize <= this->m_nMaxSize);
627// ASSERT(is_memory_segment_ok(this->m_pData, (::memsize_cast) this->m_nMaxSize * sizeof(TYPE)));
628//
629// }
630//
631//}
632
633
634//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
635//typename raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::iterator raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase(iterator pos)
636//{
637// if(pos.m_parray == this)
638// {
639// this->erase_at(pos.m_i);
640// return iterator(pos.m_i, this);
641// }
642// else
643// {
644// return this->end();
645// }
646//}
647
648//template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
649//typename raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::iterator raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::erase(iterator begin, iterator last)
650//{
651// if(begin.m_parray == this && last.m_parray == this)
652// {
653// if(begin.m_i >= 0 && begin.m_i < this->get_size())
654// {
655// ::collection::count nCount = last.m_i - begin.m_i;
656// erase_at(begin.m_i, nCount);
657// return iterator(begin.m_i, this);
658// }
659// else
660// {
661// return this->end();
662// }
663// }
664// else
665// {
666// return this->end();
667// }
668//}
669//
670//
671template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
672::collection::index raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::raw_find_first(TYPE *point, ::collection::index find, ::collection::index last) const
673{
674 if(find < 0)
675 find += this->get_count();
676 if(last < 0)
677 last += this->get_count();
678 for(; find <= last; find++)
679 {
680 if(&this->element_at(find) == point)
681 return find;
682 }
683 return -1;
684}
685template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
686::collection::index raw_array < 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
687
688{
689 if(find < 0)
690 find += this->get_count();
691 if(last < 0)
692 last += this->get_count();
693 for(; find <= last; find++)
694 {
695 if(pfnCompare((ARG_TYPE)this->element_at(find), (ARG_TYPE)t) == 0)
696
697 return find;
698 }
699 return -1;
700}
701
702
703
704
705template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
706raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::operator += (const raw_array & a)
707{
708
709 if(&a == this)
710 {
711 raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > aCopy(a);
712 add(aCopy);
713 }
714 else
715 {
716 add(a);
717 }
718 return *this;
719
720}
721
722template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
723raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::operator + (const raw_array & a) const
724{
725 raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > aNew(*this);
726 aNew += a;
727 return a;
728}
729
730
731
732
733
734
735
736
737template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
738inline raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::operator =(raw_array && a)
739{
740
741 return transfer(::transfer(a));
742
743}
744
745
746
747
748
749template < typename TYPE, typename ARG_TYPE, typename ALLOCATOR, ::enum_type t_etypeContainer >
750inline raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer > & raw_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::transfer(raw_array && a)
751{
752
753 if (&a != this)
754 {
755 this->destroy();
756
757 this->m_nGrowBy = a.m_nGrowBy;
758 this->m_pData = a.m_pData;
759 this->m_nSize = a.m_nSize;
760 this->m_nMaxSize = a.m_nMaxSize;
761
762 a.m_pData = nullptr;
763
764 }
765
766 return *this;
767
768}
769
770
771
772
773
774
775
776
777
778
779
780
781
Definition item.h:93
Definition particle.h:95