...continuing
This commit is contained in:
parent
3fde2b9f66
commit
b63d56e315
9 changed files with 133 additions and 179 deletions
|
@ -51,6 +51,9 @@ namespace MultiArrayTools
|
|||
// range_base.h
|
||||
class MultiRangeType;
|
||||
|
||||
// range_base.h
|
||||
class IndefinitRangeBase;
|
||||
|
||||
// range_base.h
|
||||
template <class Index>
|
||||
class RangeBase;
|
||||
|
|
|
@ -7,37 +7,68 @@ namespace MultiArrayTools
|
|||
* IndefinitIndexBase *
|
||||
************************/
|
||||
|
||||
IndefinitIndexBase::~IndefinitIndexBase()
|
||||
{
|
||||
mMajor = nullptr;
|
||||
}
|
||||
|
||||
size_t IndefinitIndexBase::pos() const
|
||||
{
|
||||
//assert(not virt());
|
||||
return static_cast<size_t>( mPos );
|
||||
}
|
||||
|
||||
void IndefinitIndexBase::setPos(size_t pos)
|
||||
bool IndefinitIndexBase::operator==(const IndefinitIndexBase& i) const
|
||||
{
|
||||
//CHECK;
|
||||
//assert(not virt());
|
||||
mPos = pos;
|
||||
return rangeType() == in.rangeType() and pos() == in.pos();
|
||||
}
|
||||
|
||||
void IndefinitIndexBase::setPosRel(int relPos)
|
||||
bool IndefinitIndexBase::operator!=(const IndefinitIndexBase& i) const
|
||||
{
|
||||
return rangeType() != in.rangeType() or pos() != in.pos();
|
||||
}
|
||||
|
||||
IndefinitIndexBase& IndefinitIndexBase::setPos(size_t pos, IndefinitIndexBase* ctrlPtr)
|
||||
{
|
||||
mPos = pos;
|
||||
for(auto mm: mMajor){
|
||||
if(mm.first == ctrlPtr){
|
||||
continue;
|
||||
}
|
||||
mm.first->setPos(mm.first->pos() % mm.second + mm.second * pos, this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
IndefinitIndexBase& IndefinitIndexBase::setPosRel(int relPos, IndefinitIndexBase* ctrlPtr)
|
||||
{
|
||||
mPos += relPos;
|
||||
for(auto mm: mMajor){
|
||||
if(mm.first == ctrlPtr){
|
||||
continue;
|
||||
}
|
||||
// MAJOR INDEX UPDATE !!!!!
|
||||
void IndefinitIndexBase::toFirst()
|
||||
{
|
||||
mPos = 0;
|
||||
mm.first->setPosRel(mm.second * relPos, this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void IndefinitIndexBase::toLast()
|
||||
IndefinitIndexBase& IndefinitIndexBase::toFirst(IndefinitIndexBase* ctrlPtr)
|
||||
{
|
||||
mPos = 0;
|
||||
for(auto mm: mMajor){
|
||||
if(mm.first == ctrlPtr){
|
||||
continue;
|
||||
}
|
||||
mm.first->setPos(mm.first->pos() % mm.second, this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
IndefinitIndexBase& IndefinitIndexBase::toLast(IndefinitIndexBase* ctrlPtr)
|
||||
{
|
||||
mPos = max() - 1;
|
||||
for(auto mm: mMajor){
|
||||
if(mm.first == ctrlPtr){
|
||||
continue;
|
||||
}
|
||||
mm.first->setPos(mm.first->pos() % mm.second + mm.second * mPos, this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
int IndefinitIndexBase::outOfRange() const
|
||||
|
@ -58,49 +89,15 @@ namespace MultiArrayTools
|
|||
return mPos == max();
|
||||
}
|
||||
|
||||
bool IndefinitIndexBase::toNull() const
|
||||
bool IndefinitIndexBase::master() const
|
||||
{
|
||||
//assert(not virt());
|
||||
return true;
|
||||
return mMajor.size() == 0;
|
||||
}
|
||||
|
||||
void IndefinitIndexBase::evalMajor()
|
||||
IndefinitIndexBase& IndefinitIndexBase::subOrd(IndefinitIndexBase* major)
|
||||
{
|
||||
//assert(not virt());
|
||||
if(not master()){
|
||||
//int start = mMajor->pos();
|
||||
mMajor->eval();
|
||||
//VCHECK(static_cast<int>( mMajor->pos() ) - start);
|
||||
}
|
||||
}
|
||||
|
||||
void IndefinitIndexBase::evalMajor(int num)
|
||||
{
|
||||
//assert(not virt());
|
||||
//CHECK;
|
||||
if(not master()){
|
||||
//int start = mMajor->pos();
|
||||
mMajor->setPosRel( num * mMajorStep);
|
||||
//VCHECK(static_cast<int>( mMajor->pos() ) - start);
|
||||
}
|
||||
}
|
||||
|
||||
bool IndefinitIndexBase::master()
|
||||
{
|
||||
//assert(not virt());
|
||||
return mMajor == nullptr;
|
||||
}
|
||||
|
||||
void IndefinitIndexBase::subOrd(IndefinitIndexBase* major)
|
||||
{
|
||||
//assert(not virt());
|
||||
mMajor = major;
|
||||
mMajorStep = mMajor->giveSubStepSize(this);
|
||||
}
|
||||
|
||||
size_t IndefinitIndexBase::majorStep() const
|
||||
{
|
||||
return mMajorStep;
|
||||
mMajor[major] = major->giveSubStepSize(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**************
|
||||
|
@ -117,13 +114,6 @@ namespace MultiArrayTools
|
|||
return mRange->size();
|
||||
}
|
||||
|
||||
template <class Index>
|
||||
bool IndexBase<Index>::toNull() const
|
||||
{
|
||||
//assert(not virt());
|
||||
return mRange == nullptr;
|
||||
}
|
||||
|
||||
template <class Index>
|
||||
void IndexBase<Index>::assignRange(RangeBase<Index> const* range)
|
||||
{
|
||||
|
@ -132,10 +122,4 @@ namespace MultiArrayTools
|
|||
mRange = range;
|
||||
}
|
||||
}
|
||||
|
||||
template <class Index>
|
||||
void IndexBase<Index>::eval()
|
||||
{
|
||||
setPos( evaluate(*dynamic_cast<Index const*>( this )) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace MultiArrayTools
|
|||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(IndefinitIndexBase);
|
||||
virtual ~IndefinitIndexBase();
|
||||
virtual ~IndefinitIndexBase() = default;
|
||||
|
||||
virtual IndefinitIndexBase& operator=(size_t pos) = 0;
|
||||
virtual IndefinitIndexBase& operator++() = 0;
|
||||
|
@ -26,32 +26,26 @@ namespace MultiArrayTools
|
|||
virtual IndefinitIndexBase& operator+=(int n) = 0;
|
||||
virtual IndefinitIndexBase& operator-=(int n) = 0;
|
||||
|
||||
// Make this somehow better... !!!
|
||||
//virtual bool operator==(const IndefinitIndexBase& i) = 0;
|
||||
//virtual bool operator!=(const IndefinitIndexBase& i) = 0;
|
||||
bool operator==(const IndefinitIndexBase& i) const;
|
||||
bool operator!=(const IndefinitIndexBase& i) const;
|
||||
|
||||
virtual size_t dim() const = 0;
|
||||
virtual size_t pos() const;
|
||||
|
||||
virtual MultiRangeType rangeType() const = 0;
|
||||
|
||||
virtual void setPos(size_t pos);
|
||||
virtual void setPosRel(int relPos);
|
||||
virtual IndefinitIndexBase& setPos(size_t pos, IndefinitIndexBase* ctrlPtr = nullptr);
|
||||
virtual IndefinitIndexBase& setPosRel(int relPos, IndefinitIndexBase* ctrlPtr = nullptr);
|
||||
|
||||
virtual IndefinitIndexBase& toFirst();
|
||||
virtual IndefinitIndexBase& toLast();
|
||||
virtual IndefinitIndexBase& toFirst(IndefinitIndexBase* ctrlPtr = nullptr);
|
||||
virtual IndefinitIndexBase& toLast(IndefinitIndexBase* ctrlPtr = nullptr);
|
||||
|
||||
virtual size_t max() const = 0;
|
||||
virtual int outOfRange() const;
|
||||
virtual bool atEdge() const;
|
||||
virtual bool toNull() const;
|
||||
virtual bool master() const;
|
||||
|
||||
virtual void eval() = 0;
|
||||
virtual void evalMajor();
|
||||
virtual void evalMajor(int num);
|
||||
virtual bool master();
|
||||
|
||||
virtual void subOrd(IndefinitIndexBase* major);
|
||||
virtual IndefinitIndexBase& subOrd(IndefinitIndexBase* major);
|
||||
virtual size_t giveSubStepSize(IndefinitIndexBase* subIndex) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -72,11 +66,8 @@ namespace MultiArrayTools
|
|||
|
||||
//virtual size_t pos() const override; // = mPos; implement !!!
|
||||
virtual size_t max() const override;
|
||||
virtual bool toNull() const override;
|
||||
|
||||
virtual void assignRange(RangeBase<Index> const* range);
|
||||
|
||||
virtual void eval() override;
|
||||
virtual void copyPos(const Index& in) = 0;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -469,14 +469,15 @@ namespace MultiArrayTools
|
|||
mIndex = dynamic_cast<typename TotalInRange::IndexType const&>( in.index() );
|
||||
|
||||
mNm = in.name();
|
||||
mIndex.name(mNm); // to be sure...
|
||||
|
||||
typename TotalInRange::IndexType endIndex = mIndex;
|
||||
endIndex.setPos( mIndex.max() );
|
||||
++endIndex.toLast();
|
||||
|
||||
std::cout << "map assignment: " << endIndex.pos() << " elements" << std::endl;
|
||||
|
||||
// !!!!!
|
||||
IndexList il = in.getIndices();
|
||||
setInternalIndex(il);
|
||||
in.setInternalIndex(il);
|
||||
|
||||
MultiArray<T,TotalRange> cnt(mRoot->range());
|
||||
MultiArrayOperationRoot<T,TotalRange> cnto(cnt, mRoot.name());
|
||||
|
@ -485,7 +486,6 @@ namespace MultiArrayTools
|
|||
get() += in.get();
|
||||
cnto.get() += 1.;
|
||||
}
|
||||
mRoot.freeIndex();
|
||||
// CHECK whether T / size_t mixture works!!
|
||||
mRoot /= cnt(mRoot.name(), true);
|
||||
return *this;
|
||||
|
@ -497,16 +497,17 @@ namespace MultiArrayTools
|
|||
operator=(const ConstMultiArrayOperationRoot<T,TotalInRange>& in)
|
||||
{
|
||||
mIndex = dynamic_cast<typename TotalInRange::IndexType const&>( in.index() );
|
||||
|
||||
mNm = in.name();
|
||||
mIndex.name(mNm); // to be sure...
|
||||
|
||||
typename TotalInRange::IndexType endIndex = mIndex;
|
||||
++endIndex.toLast();
|
||||
|
||||
std::cout << "map assignment: " << endIndex.pos() << " elements" << std::endl;
|
||||
|
||||
//!!!!!!!
|
||||
IndexList il = in.getIndices();
|
||||
setInternalIndex(il);
|
||||
in.setInternalIndex(il);
|
||||
|
||||
MultiArray<T,TotalRange> cnt(mRoot->range());
|
||||
MultiArrayOperationRoot<T,TotalRange> cnto(cnt, mRoot.name());
|
||||
for(mIndex.toFirst(), mMF.eval(); mIndex != endIndex; ++mIndex, mMF.eval()){
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace MultiArrayTools
|
||||
{
|
||||
|
||||
typedef std::vector<std::shared_ptr<IndefinitIndexBase> > IndexList;
|
||||
typedef std::map<Name,std::shared_ptr<IndefinitIndexBase> > IndexList;
|
||||
|
||||
template <typename T>
|
||||
class MultiArrayOperationBase
|
||||
|
@ -29,12 +29,8 @@ namespace MultiArrayTools
|
|||
const IndefinitIndexBase& index() const = 0;
|
||||
|
||||
virtual const T& get() const = 0;
|
||||
|
||||
virtual IndexList getIndices() const = 0;
|
||||
virtual void setInternalIndex(const IndexList& il) = 0;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
class MutableMultiArrayOperationBase : public MultiArrayOperationBase<T>
|
||||
{
|
||||
|
@ -143,7 +139,6 @@ namespace MultiArrayTools
|
|||
virtual const T& get() const override;
|
||||
|
||||
const Name& name() const;
|
||||
|
||||
const MultiArrayBase<T,Range>& getCont() const { return mArrayRef; }
|
||||
|
||||
template <typename U, class RangeX>
|
||||
|
@ -216,7 +211,6 @@ namespace MultiArrayTools
|
|||
virtual const T& get() const override;
|
||||
|
||||
const Name& name() const;
|
||||
|
||||
const MultiArrayBase<T,Range>& getCont() const { return mArrayRef; }
|
||||
|
||||
template <typename U, class RangeX>
|
||||
|
@ -250,6 +244,7 @@ namespace MultiArrayTools
|
|||
|
||||
virtual const T& get() const override;
|
||||
virtual T& get() override;
|
||||
|
||||
// !!!!
|
||||
protected:
|
||||
IndexMapFunction<InRange,OutRange> mMF;
|
||||
|
@ -297,7 +292,6 @@ namespace MultiArrayTools
|
|||
auto operator/(const MAOp2& sec) -> decltype(operator()(std::divides<T>(), sec));
|
||||
|
||||
virtual size_t argNum() const override;
|
||||
|
||||
virtual const T& get() const override;
|
||||
|
||||
protected:
|
||||
|
@ -355,7 +349,6 @@ namespace MultiArrayTools
|
|||
auto operator/(const MAOp2& sec) -> decltype(operator()(std::divides<T>(), sec));
|
||||
|
||||
virtual size_t argNum() const override;
|
||||
|
||||
virtual const T& get() const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -77,17 +77,18 @@ namespace MultiArrayTools
|
|||
template <size_t DIGIT>
|
||||
struct SubIteration
|
||||
{
|
||||
// use 'plus' as few as possible !!
|
||||
template <class MultiIndex>
|
||||
static inline void plus(MultiIndex& index, int num)
|
||||
{
|
||||
auto& si = index.template getIndex<DIGIT>();
|
||||
si.setPosRel(num);
|
||||
si.setPosRel(num, &index);
|
||||
size_t oor = si.outOfRange();
|
||||
if(oor > 0){
|
||||
while(oor > 0){
|
||||
SubIteration<DIGIT-1>::pp(index);
|
||||
SubIteration<DIGIT>::plus(index, -si.max());
|
||||
}
|
||||
else if(oor < 0){
|
||||
while(oor < 0){
|
||||
SubIteration<DIGIT-1>::mm(index);
|
||||
SubIteration<DIGIT>::plus(index, si.max());
|
||||
}
|
||||
|
@ -97,13 +98,12 @@ namespace MultiArrayTools
|
|||
static inline void pp(MultiIndex& index)
|
||||
{
|
||||
auto& si = index.template getIndex<DIGIT>();
|
||||
//IndefinitIndexBase& si = index.get(DIGIT);
|
||||
if(si.pos() == si.max()-1){
|
||||
si.setPos(0);
|
||||
if(si.pos() == si.atEdge()){
|
||||
si.setPos(0, &index);
|
||||
SubIteration<DIGIT-1>::pp(index);
|
||||
}
|
||||
else {
|
||||
si.setPosRel(1);
|
||||
si.setPosRel(1, &index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,13 +111,12 @@ namespace MultiArrayTools
|
|||
static inline void mm(MultiIndex& index)
|
||||
{
|
||||
auto& si = index.template getIndex<DIGIT>();
|
||||
//IndefinitIndexBase& si = index.get(DIGIT);
|
||||
if(si.pos() == si.max()-1){
|
||||
si.setPos(si.max()-1);
|
||||
if(si.pos() == si.atEdge()){
|
||||
si.setPos(si.atEdge(), &index);
|
||||
SubIteration<DIGIT-1>::mm(index);
|
||||
}
|
||||
else {
|
||||
si.setPosRel(1);
|
||||
si.setPosRel(1, &index);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -129,45 +128,21 @@ namespace MultiArrayTools
|
|||
static inline void plus(MultiIndex& index, int num)
|
||||
{
|
||||
auto& si = index.template getIndex<0>();
|
||||
//IndefinitIndexBase& si = index.get(0);
|
||||
si.setPosRel(num);
|
||||
si.setPosRel(num, &index);
|
||||
}
|
||||
|
||||
template <class MultiIndex>
|
||||
static inline void pp(MultiIndex& index)
|
||||
{
|
||||
auto& si = index.template getIndex<0>();
|
||||
//IndefinitIndexBase& si = index.get(0);
|
||||
si.setPosRel(1);
|
||||
si.setPosRel(1, &index);
|
||||
}
|
||||
|
||||
template <class MultiIndex>
|
||||
static inline void mm(MultiIndex& index)
|
||||
{
|
||||
auto& si = index.template getIndex<0>();
|
||||
//IndefinitIndexBase& si = index.get(0);
|
||||
si.setPosRel(-1);
|
||||
}
|
||||
};
|
||||
|
||||
template <size_t N>
|
||||
struct TupleNamer
|
||||
{
|
||||
template <class IndexPack, class Name>
|
||||
static void nameTuple(IndexPack& iPack, Name& name)
|
||||
{
|
||||
std::get<N>(iPack).name(name.get(N));
|
||||
TupleNamer<N-1>::nameTuple(iPack, name);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct TupleNamer<0>
|
||||
{
|
||||
template <class IndexPack, class Name>
|
||||
static void nameTuple(IndexPack& iPack, Name& name)
|
||||
{
|
||||
std::get<0>(iPack).name(name.get(0));
|
||||
si.setPosRel(-1, &index);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -415,6 +390,10 @@ namespace MultiArrayTools
|
|||
IIB::mPos = evaluate(*this);
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
MultiIndex<Indices...>::MultiIndex(std::vector<std::shared_ptr<IndefinitIndexBase> >& indexList) :
|
||||
// !!!!
|
||||
|
||||
template <class... Indices>
|
||||
MultiIndex<Indices...>& MultiIndex<Indices...>::operator++()
|
||||
{
|
||||
|
@ -464,7 +443,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
template <class... Indices>
|
||||
IndefinitIndexBase& MultiIndex<Indices...>::operator=(size_t pos)
|
||||
MultiIndex<Indices...>& MultiIndex<Indices...>::operator=(size_t pos)
|
||||
{
|
||||
IIB::setPos( pos );
|
||||
IndexPackSetter<sizeof...(Indices)-1>::setIndexPack(mIPack, pos);
|
||||
|
@ -484,20 +463,6 @@ namespace MultiArrayTools
|
|||
return res;
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
void MultiIndex<Indices...>::name(const Name& nm)
|
||||
{
|
||||
IIB::mName = nm.own();
|
||||
if(nm.size() >= sizeof...(Indices)){
|
||||
TupleNamer<sizeof...(Indices)-1>::nameTuple(mIPack, nm);
|
||||
}
|
||||
else {
|
||||
Name nm2 = nm;
|
||||
nm2.autoName(sizeof...(Indices));
|
||||
TupleNamer<sizeof...(Indices)-1>::nameTuple(mIPack, nm2);
|
||||
}
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
MultiIndex<Indices...>& MultiIndex<Indices...>::operator()(Indices&&... inds)
|
||||
{
|
||||
|
@ -685,6 +650,15 @@ namespace MultiArrayTools
|
|||
IndexSetter<sizeof...(Ranges)-1>::setEnd(is,mSpace);
|
||||
return ++MultiIndex<typename Ranges::IndexType...>(this, is);
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
std::shared_ptr<IndefinitIndexBase> MultiRange<Ranges...>::indexInstance() const
|
||||
{
|
||||
std::tuple<std::shared_ptr<typename Ranges::IndexType>...> is;
|
||||
IndexSetter<sizeof...(Ranges)-1>::setBegin(is,mSpace);
|
||||
std::shared_ptr<IndefinitIndexBase> sptr(new MultiIndex<typename Ranges::IndexType...>(this, is));
|
||||
return sptr;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Ts>
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace MultiArrayTools
|
|||
MultiIndex(RangeBase<MultiIndex<std::shared_ptr<Indices>...> > const* range,
|
||||
const IndexPack& ipack);
|
||||
|
||||
//virtual ~MultiIndex();
|
||||
MultiIndex(std::vector<std::shared_ptr<IndefinitIndexBase> >& indexList);
|
||||
|
||||
virtual MultiIndex& operator++() override;
|
||||
virtual MultiIndex& operator--() override;
|
||||
|
@ -57,15 +57,15 @@ namespace MultiArrayTools
|
|||
bool operator==(const MultiIndex& in);
|
||||
bool operator!=(const MultiIndex& in);
|
||||
|
||||
virtual IIB& operator=(size_t pos) override;
|
||||
virtual MultiIndex& operator=(size_t pos) override;
|
||||
virtual MultiRangeType rangeType() const override;
|
||||
|
||||
template <size_t N>
|
||||
auto getIndex() ->;
|
||||
auto getIndex() -> decltype(*std::get<N>(mIPack))&;
|
||||
//typename std::tuple_element<N, std::tuple<std::shared_ptr<Indices>...> >::type& getIndex();
|
||||
|
||||
template <size_t N>
|
||||
auto getIndex() const ->;
|
||||
auto getIndex() const -> decltype(*std::get<N>(mIPack))&;
|
||||
//typename std::tuple_element<N, std::tuple<std::shared_ptr<Indices>...> >::type const& getIndex() const;
|
||||
|
||||
IndefinitIndexBase& get(size_t n);
|
||||
|
@ -77,18 +77,9 @@ namespace MultiArrayTools
|
|||
MultiIndex& operator()(Indices&&... inds);
|
||||
MultiIndex& operator()(const Indices&... inds);
|
||||
|
||||
virtual void name(const Name& nm) override;
|
||||
|
||||
// dimension of MultiRange; includes ALL degrees of freedom
|
||||
virtual size_t dim() const override;
|
||||
|
||||
virtual void copyPos(const MultiIndex<std::shared_ptr<Indices>...>& in) override;
|
||||
|
||||
virtual size_t giveSubStepSize(IndefinitIndexBase* subIndex) override;
|
||||
|
||||
//virtual void eval() override;
|
||||
//virtual bool virt() const override { return false; }
|
||||
//virtual void assignRange(RangeBase<MultiIndex<Indices...> > const* range) override;
|
||||
};
|
||||
|
||||
/*****************************
|
||||
|
@ -128,6 +119,8 @@ namespace MultiArrayTools
|
|||
virtual MultiIndex<typename Ranges::IndexType...> begin() const override;
|
||||
virtual MultiIndex<typename Ranges::IndexType...> end() const override;
|
||||
|
||||
virtual std::shared_ptr<IndefinitIndexBase> indexInstance() const override;
|
||||
|
||||
protected:
|
||||
SpaceType mSpace;
|
||||
};
|
||||
|
|
|
@ -113,5 +113,10 @@ namespace MultiArrayTools
|
|||
return true;
|
||||
}
|
||||
|
||||
template <class Index>
|
||||
RangeBase<Index>* SubRangeBase<Index>::base()
|
||||
{
|
||||
return mBase;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,20 +55,30 @@ namespace MultiArrayTools
|
|||
std::vector<MultiRangeType>* mMultiType;
|
||||
};
|
||||
|
||||
class IndefinitRangeBase
|
||||
{
|
||||
public:
|
||||
virtual ~IndefinitRangeBase() = default;
|
||||
|
||||
virtual size_t size() const = 0;
|
||||
virtual bool isSubRange() const = 0;
|
||||
virtual MultiRangeType type() const = 0;
|
||||
virtual std::shared_ptr<IndefinitIndexBase> indexInstance() const = 0;
|
||||
|
||||
protected:
|
||||
DEFAULT_MEMBERS(RangeBase);
|
||||
};
|
||||
|
||||
template <class Index>
|
||||
class RangeBase
|
||||
class RangeBase : public IndefinitRangeBase
|
||||
{
|
||||
public:
|
||||
typedef Index IndexType;
|
||||
|
||||
virtual ~RangeBase() = default;
|
||||
|
||||
virtual size_t size() const = 0;
|
||||
virtual Index begin() const = 0;
|
||||
virtual Index end() const = 0;
|
||||
virtual RangeBase<Index>* base();
|
||||
virtual bool isSubRange() const;
|
||||
virtual MultiRangeType type() const = 0;
|
||||
virtual bool isSubRange() const override;
|
||||
|
||||
protected:
|
||||
DEFAULT_MEMBERS(RangeBase);
|
||||
|
|
Loading…
Reference in a new issue