CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
marray.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_marray_cc_h__
13#define __cxz_marray_cc_h__
14
15#include "marray.h"
16
17namespace CNORXZ
18{
19 /*=======================================================+
20 | Implementation of MArray public member functions |
21 +=======================================================*/
22
23 template <typename T>
25 ArrayBase<T>(range), mCont(range->size())
26 {}
27
28 template <typename T>
29 MArray<T>::MArray(const RangePtr& range, const Vector<T>& vec) :
30 ArrayBase<T>(range), mCont(vec)
31 {}
32
33 template <typename T>
34 MArray<T>::MArray(const RangePtr& range, Vector<T>&& vec) :
35 ArrayBase<T>(range), mCont(vec)
36 {}
38 template <typename T>
40 {
41 AB::mRange = rangeCast<YRange>(range);
42 mCont.resize(AB::mRange->size());
43 return *this;
44 }
46 template <typename T>
48 {
49 if(AB::mRange == nullptr) {
50 return this->init(range);
51 }
52 MArray<T> tmp(AB::mRange->extend(range));
53 auto ei = this->end();
54 auto ti = tmp.begin();
55 // this is not very efficient; remove by sub-index operation once available:
56 for(auto ii = this->begin(); ii != ei; ++ii){
57 ti.at(ii.meta());
58 *ti = *ii;
59 }
60 *this = std::move(tmp);
61 return *this;
62 }
63
64 template <typename T>
65 const T* MArray<T>::data() const
66 {
67 return mCont.data();
68 }
69
70 template <typename T>
72 {
73 return mCont.data();
74 }
75
76 template <typename T>
78 {
79 return const_iterator(mCont.data(), AB::mRange);
80 }
81
82 template <typename T>
84 {
85 return const_iterator(mCont.data(), AB::mRange, mCont.size());
86 }
87
88 template <typename T>
89 bool MArray<T>::isView() const
90 {
91 return false;
92 }
93
94 /*==========================================================+
95 | Implementation of MArray protected member functions |
96 +==========================================================*/
97
98 template <typename T>
100 {
101 return true;
102 }
103}
104
105#endif
virtual const_iterator cend() const override
Definition marray.cc.h:83
virtual const_iterator cbegin() const override
Definition marray.cc.h:77
MArray & init(const RangePtr &range)
Definition marray.cc.h:39
virtual bool formatIsTrivial() const override final
Definition marray.cc.h:99
MArray(const RangePtr &range)
Definition marray.cc.h:24
MArray & extend(const RangePtr &range)
Definition marray.cc.h:47
virtual bool isView() const override
Definition marray.cc.h:89
virtual const T * data() const override
Definition marray.cc.h:65
MArray declarations.
Sptr< RangeBase > RangePtr
Definition types.h:157
std::vector< T, Allocator< T > > Vector
Definition types.h:310
Sptr< Range > rangeCast(const RangePtr r)