added single range specialization

This commit is contained in:
Christian Zimmermann 2017-03-24 15:05:02 +01:00
parent 6439542968
commit a77d58d946
2 changed files with 59 additions and 0 deletions

View file

@ -96,6 +96,41 @@ namespace MultiArrayTools
//
SingleRange<size_t,RangeType::SPACE>::SingleRange(size_t ext) :
RangeBase<SingleIndex<size_t,RangeType::SPACE> >(),
mExt(ext) {}
size_t SingleRange<size_t,RangeType::SPACE>::get(size_t pos) const
{
return pos;
}
size_t SingleRange<size_t,RangeType::SPACE>::getMeta(size_t metaPos) const
{
return metaPos;
}
size_t SingleRange<size_t,RangeType::SPACE>::size() const
{
return mExt;
}
MultiRangeType SingleRange<size_t,RangeType::SPACE>::type() const
{
return MultiRangeType(RangeType::SPACE);
}
SingleIndex<size_t,RangeType::SPACE> SingleRange<size_t,RangeType::SPACE>::begin() const
{
return SingleIndex<size_t,RangeType::SPACE>(this, 0);
}
SingleIndex<size_t,RangeType::SPACE> SingleRange<size_t,RangeType::SPACE>::end() const
{
return SingleIndex<size_t,RangeType::SPACE>(this, size());
}
//
SingleRange<size_t,RangeType::ENSEMBLE>::SingleRange(size_t num) :
RangeBase<SingleIndex<size_t,RangeType::ENSEMBLE> >(),

View file

@ -112,6 +112,30 @@ namespace MultiArrayTools
size_t mExt;
};
template <>
class SingleRange<size_t,RangeType::SPACE> : public RangeBase<SingleIndex<size_t,RangeType::SPACE> >
{
public:
typedef typename RangeBase<SingleIndex<int,RangeType::SPACE> >::IndexType IndexType;
DEFAULT_MEMBERS(SingleRange);
SingleRange(size_t ext);
virtual size_t size() const override;
size_t get(size_t pos) const;
size_t getMeta(size_t metaPos) const;
virtual MultiRangeType type() const override;
SingleIndex<size_t,RangeType::SPACE> begin() const override;
SingleIndex<size_t,RangeType::SPACE> end() const override;
protected:
size_t mExt;
};
template <>
class SingleRange<size_t,RangeType::ENSEMBLE> : public RangeBase<SingleIndex<size_t,RangeType::ENSEMBLE> >
{