CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
urange.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_urange_h__
13#define __cxz_urange_h__
14
15#include "base/base.h"
16#include "ranges/index_base.h"
17#include "ranges/range_base.h"
18#include "xpr/xpr.h"
19
20#include <iterator>
21
22namespace CNORXZ
23{
24
29 template <typename MetaT>
30 class UIndex : public IndexInterface<UIndex<MetaT>,MetaT>
31 {
32 public:
33
36 typedef MetaT MetaType;
37
45 UIndex(const RangePtr& range, SizeT pos = 0);
46
49
52
55
57 UIndex operator+(Int n) const;
58
60 UIndex operator-(Int n) const;
61
63 SizeT operator-(const UIndex& i) const;
64
67
70
72 SizeT lex() const;
73
75 UPos pmax() const;
76
78 UPos lmax() const;
79
81 IndexId<0> id() const;
82
84 const MetaT& operator*() const;
85
87 SizeT dim() const; // = 1
88
90 Sptr<RangeType> range() const;
91
93 template <SizeT I>
94 decltype(auto) stepSize(const IndexId<I>& id) const;
95
97 String stringMeta() const;
98
100 const MetaT& meta() const;
101
103 UIndex& at(const MetaT& metaPos);
104
106 RangePtr prange(const UIndex<MetaType>& last) const;
107
109 SizeT deepFormat() const;
110
112 SizeT deepMax() const;
113
115 UIndex& reformat(const Vector<SizeT>& f, const Vector<SizeT>& s);
116
118 template <class Xpr, class F>
119 decltype(auto) ifor(const Xpr& xpr, F&& f) const;
120
122 bool formatIsTrivial() const;
123
125 decltype(auto) xpr(const Sptr<UIndex<MetaType>>& _this) const;
126
127 private:
128 Sptr<RangeType> mRangePtr;
129 const MetaT* mMetaPtr;
130 };
131
132 template <typename MetaT>
133 void swap(UIndex<MetaT>& a, UIndex<MetaT>& b) { a.swap(b); }
134
139 template <typename MetaT, class I1>
140 decltype(auto) operator*(const Sptr<UIndex<MetaT>>& a, const Sptr<I1>& b);
141
146 template <typename MetaT>
148 {
149 public:
150 URangeFactory(const Vector<MetaT>& space);
152 URangeFactory(const Vector<MetaT>& space, const RangePtr& ref);
153 URangeFactory(Vector<MetaT>&& space, const RangePtr& ref);
154
155 private:
156 URangeFactory() = default;
157 virtual void make() override final;
158
159 Vector<MetaT> mSpace;
160 RangePtr mRef;
161 };
162
168 template <typename MetaT>
169 class URange : public RangeInterface<URange<MetaT>>
170 {
171 public:
172 typedef RangeBase RB;
175
177
178 virtual SizeT size() const override final;
184
190
195
201
202 private:
203
204 URange() = default;
206 URange(const Vector<MetaType>& space);
207 URange(Vector<MetaType>&& space);
208
209 Vector<MetaType> mSpace;
210
212
213 SERIALIZATION_FUNCTIONS_NOPUB;
214 };
215
226
231 template <typename MetaT>
232 RangePtr urange(const Vector<MetaT>& space);
233
238 template <typename MetaT>
240 {
241 static constexpr bool value = true;
242 };
243}
244
245#endif
basic headers
UIndex & operator++()
Definition urange.cc.h:46
RangePtr prange(const UIndex< MetaType > &last) const
Definition urange.cc.h:147
SizeT lex() const
Definition urange.cc.h:92
UIndex & reformat(const Vector< SizeT > &f, const Vector< SizeT > &s)
Definition urange.cc.h:172
UIndex & operator--()
Definition urange.cc.h:53
UIndex & operator=(SizeT lexpos)
Definition urange.cc.h:39
UIndex operator+(Int n) const
Definition urange.cc.h:60
decltype(auto) xpr(const Sptr< UIndex< MetaType > > &_this) const
Definition urange.cc.h:141
decltype(auto) ifor(const Xpr &xpr, F &&f) const
Definition urange.cc.h:207
SizeT deepFormat() const
Definition urange.cc.h:160
UIndex & at(const MetaT &metaPos)
Definition urange.cc.h:134
SizeT deepMax() const
Definition urange.cc.h:166
UIndex & operator+=(Int n)
Definition urange.cc.h:78
decltype(auto) stepSize(const IndexId< I > &id) const
Definition urange.cc.h:195
URange< MetaT > RangeType
Definition urange.h:35
UPos pmax() const
Definition urange.cc.h:98
INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType)
bool formatIsTrivial() const
Definition urange.cc.h:213
MetaT MetaType
Definition urange.h:36
Sptr< RangeType > range() const
Definition urange.cc.h:188
SizeT dim() const
Definition urange.cc.h:182
String stringMeta() const
Definition urange.cc.h:122
const MetaT & operator*() const
Definition urange.cc.h:116
UIndex operator-(Int n) const
Definition urange.cc.h:66
UIndex & operator-=(Int n)
Definition urange.cc.h:85
IndexId< 0 > id() const
Definition urange.cc.h:110
UIndex(const RangePtr &range, SizeT pos=0)
Definition urange.cc.h:32
UPos lmax() const
Definition urange.cc.h:104
IndexInterface< UIndex< MetaT >, MetaT > IB
Definition urange.h:34
const MetaT & meta() const
Definition urange.cc.h:128
DEFAULT_MEMBERS(UIndex)
RangeBase RB
Definition urange.h:172
const MetaType * get() const
Definition urange.cc.h:291
UIndex< MetaT > IndexType
Definition urange.h:173
MetaT MetaType
Definition urange.h:174
virtual SizeT dim() const override final
Definition urange.cc.h:314
virtual const TypeInfo & type() const override final
Definition urange.cc.h:326
virtual String stringMeta(SizeT pos) const override final
Definition urange.cc.h:320
virtual RangePtr extend(const RangePtr &r) const override final
Definition urange.cc.h:338
SizeT getMeta(const MetaType &metaPos) const
Definition urange.cc.h:297
virtual const TypeInfo & metaType() const override final
Definition urange.cc.h:332
virtual SizeT size() const override final
Definition urange.cc.h:308
Index base declaration.
std::string String
Definition types.h:42
std::type_info TypeInfo
Definition types.h:71
RangePtr urange(const Vector< MetaT > &space)
Definition urange.cc.h:467
uint64_t SizeT
Definition types.h:38
Sptr< RangeBase > RangePtr
Definition types.h:157
std::vector< T, Allocator< T > > Vector
Definition types.h:310
int32_t Int
Definition types.h:36
Sptr< Range > rangeCast(const RangePtr r)
std::shared_ptr< T > Sptr
Definition types.h:48
void swap(UIndex< MetaT > &a, UIndex< MetaT > &b)
Definition urange.h:133
RangeBase declaration.
static Sptr< URange< MetaType > > func(const RangePtr &r)
Xpression main header.