isMeta function in single range/index

This commit is contained in:
Christian Zimmermann 2018-10-14 16:59:27 +02:00
parent a4d0c380dc
commit 610994e52f

View file

@ -65,6 +65,8 @@ namespace MultiArrayTools
SingleIndex& at(const U& metaPos); SingleIndex& at(const U& metaPos);
size_t posAt(const U& metaPos) const; size_t posAt(const U& metaPos) const;
bool isMeta(const U& metaPos) const;
size_t dim(); // = 1 size_t dim(); // = 1
bool last(); bool last();
bool first(); bool first();
@ -126,6 +128,7 @@ namespace MultiArrayTools
} }
size_t at(const U& in) const { return mMap.at(in); } size_t at(const U& in) const { return mMap.at(in); }
size_t count(const U& in) const { return mMap.count(in); }
}; };
template <> template <>
@ -198,6 +201,8 @@ namespace MultiArrayTools
virtual std::string stringMeta(size_t pos) const final; virtual std::string stringMeta(size_t pos) const final;
virtual std::vector<char> data() const final; virtual std::vector<char> data() const final;
bool isMeta(const U& metaPos) const;
const U& get(size_t pos) const; const U& get(size_t pos) const;
size_t getMeta(const U& metaPos) const; size_t getMeta(const U& metaPos) const;
@ -334,6 +339,12 @@ namespace MultiArrayTools
return mMetaPtr; return mMetaPtr;
} }
template <typename U, SpaceType TYPE>
bool SingleIndex<U,TYPE>::isMeta(const U& metaPos) const
{
return mExplicitRangePtr->isMeta(metaPos);
}
template <typename U, SpaceType TYPE> template <typename U, SpaceType TYPE>
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::at(const U& metaPos) SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::at(const U& metaPos)
{ {
@ -472,6 +483,12 @@ namespace MultiArrayTools
return 1; return 1;
} }
template <typename U, SpaceType TYPE>
bool SingleRange<U,TYPE>::isMeta(const U& metaPos) const
{
return mMSpace.count(metaPos) != 0;
}
template <typename U, SpaceType TYPE> template <typename U, SpaceType TYPE>
SpaceType SingleRange<U,TYPE>::spaceType() const SpaceType SingleRange<U,TYPE>::spaceType() const
{ {