CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
array_base.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_array_base_h__
13#define __cxz_array_base_h__
14
15#include <cstdlib>
16#include <vector>
17#include <memory>
18#include <algorithm>
19
20#include "base/base.h"
21#include "aindex.h"
22#include "operation/op_types.h"
23
24namespace CNORXZ
25{
32 template <typename T>
34 {
35 public:
44
46 virtual ~CArrayBase() = default;
47
53 template <typename I, typename M>
54 const T& operator[](const IndexInterface<I,M>& i) const;
55
62 template <typename I, typename M>
63 const T& at(const IndexInterface<I,M>& i) const;
64
70 template <class... Indices>
71 const T& operator[](const SPack<Indices...>& pack) const;
72
79 template <class... Indices>
80 const T& at(const SPack<Indices...>& pack) const;
81
85 const T& operator[](const DPack& pack) const;
86
91 const T& at(const DPack& pack) const;
92
99 template <typename I, typename M>
101 const IndexInterface<I,M>& end) const;
102
107 template <class Index>
109
114 template <class... Indices>
115 inline decltype(auto) operator()(const SPack<Indices...>& pack) const;
116
120 inline decltype(auto) operator()(const DPack& pack) const;
121
123 virtual const T* data() const = 0;
124
126 virtual SizeT size() const;
127
129 virtual RangePtr range() const;
130
132 virtual const_iterator begin() const;
133
135 virtual const_iterator end() const;
136
138 virtual const_iterator cbegin() const = 0;
139
141 virtual const_iterator cend() const = 0;
142
144 virtual bool isView() const = 0;
145
146 protected:
155 template <class Acc>
156 const_iterator itLex(const Acc& acc) const;
157
165 template <class Acc>
166 const_iterator itLexSave(const Acc& acc) const;
167
172 template <class Acc>
173 void checkFormatCompatibility(const Acc& acc) const;
174
179 virtual bool formatIsTrivial() const = 0;
180 };
181
188 template <typename T>
189 class ArrayBase : public CArrayBase<T>
190 {
191 public:
196 using CAB::operator[];
197 using CAB::operator();
198 using CAB::at;
200 using CAB::begin;
201 using CAB::end;
204 using CAB::sl;
205
210 ArrayBase(const RangePtr& range);
211
214 template <typename I, typename M>
215 T& operator[](const IndexInterface<I,M>& i);
216
219 template <typename I, typename M>
220 T& at(const IndexInterface<I,M>& i);
221
224 template <class... Indices>
225 T& operator[](const SPack<Indices...>& pack);
226
229 template <class... Indices>
230 T& at(const SPack<Indices...>& pack);
231
234 T& operator[](const DPack& pack);
235
238 T& at(const DPack& pack);
239
242 template <class Index>
244
247 template <class... Indices>
248 inline decltype(auto) operator()(const SPack<Indices...>& pack);
249
252 inline decltype(auto) operator()(const DPack& pack);
253
256 template <typename I, typename M>
258 const IndexInterface<I,M>& end);
259
263 virtual T* data() = 0;
264
268 virtual iterator begin();
269
273 virtual iterator end();
274
275 protected:
276
279 template <class Acc>
280 iterator itLex(const Acc& acc);
281
284 template <class Acc>
285 iterator itLexSave(const Acc& acc);
286 };
287
288}
289
290#endif
Array index declaration.
basic headers
Sptr< ArrayBase< T > > sl(const IndexInterface< I, M > &begin, const IndexInterface< I, M > &end)
CArrayBase< T > CAB
Definition array_base.h:192
BIndex< T > iterator
Definition array_base.h:194
iterator itLex(const Acc &acc)
OpRoot< T, Index > operator()(const Sptr< Index > &i)
T & operator[](const IndexInterface< I, M > &i)
virtual iterator end()
DEFAULT_MEMBERS(ArrayBase)
virtual iterator begin()
ArrayBase(const RangePtr &range)
CAB::const_iterator const_iterator
Definition array_base.h:193
T & at(const IndexInterface< I, M > &i)
virtual T * data()=0
iterator itLexSave(const Acc &acc)
AIndex< T > const_iterator
Definition array_base.h:36
COpRoot< T, Index > operator()(const Sptr< Index > &i) const
virtual bool formatIsTrivial() const =0
CArrayBase(const RangePtr &range)
virtual const_iterator cbegin() const =0
virtual RangePtr range() const
const T & operator[](const IndexInterface< I, M > &i) const
virtual const_iterator begin() const
virtual const_iterator cend() const =0
Sptr< CArrayBase< T > > sl(const IndexInterface< I, M > &begin, const IndexInterface< I, M > &end) const
virtual bool isView() const =0
virtual const T * data() const =0
DEFAULT_MEMBERS(CArrayBase)
const T & at(const IndexInterface< I, M > &i) const
const_iterator itLex(const Acc &acc) const
void checkFormatCompatibility(const Acc &acc) const
const_iterator itLexSave(const Acc &acc) const
virtual ~CArrayBase()=default
virtual const_iterator end() const
virtual SizeT size() const
uint64_t SizeT
Definition types.h:38
Sptr< RangeBase > RangePtr
Definition types.h:157
std::shared_ptr< T > Sptr
Definition types.h:48
Operation types declarations.