clean up some parts of the code

This commit is contained in:
Christian Zimmermann 2017-03-01 10:41:29 +01:00
parent 27ddea16f6
commit 51dcbe7b92
7 changed files with 32 additions and 34 deletions

View file

@ -17,31 +17,31 @@ namespace MultiArrayTools
size_t IndefinitIndexBase::pos() const
{
assert(not virt());
//assert(not virt());
return mPos;
}
const std::string& IndefinitIndexBase::name() const
{
assert(not virt());
//assert(not virt());
return mName;
}
void IndefinitIndexBase::name(const std::string& str)
{
assert(not virt());
//assert(not virt());
mName = str;
}
void IndefinitIndexBase::name(const Name& nm)
{
assert(not virt());
//assert(not virt());
mName = nm.own();
}
bool IndefinitIndexBase::link(IndefinitIndexBase* toLink)
{
assert(not virt());
//assert(not virt());
if(toLink->rangeType() != rangeType() and toLink->name() == name()){
assert(0);
// throw !!
@ -77,13 +77,13 @@ namespace MultiArrayTools
bool IndefinitIndexBase::linked() const
{
assert(not virt());
//assert(not virt());
return mLinked != nullptr;
}
void IndefinitIndexBase::setPos(size_t pos)
{
assert(not virt());
//assert(not virt());
mPos = pos;
if(linked()){
mLinked->setPos(mPos);
@ -93,26 +93,26 @@ namespace MultiArrayTools
size_t IndefinitIndexBase::max() const
{
assert(not virt());
//assert(not virt());
return static_cast<size_t>( -1 );
}
size_t IndefinitIndexBase::outOfRange() const
{
assert(not virt());
//assert(not virt());
int res = pos() - max() + 1;
return res > 0 ? static_cast<size_t>(res) : 0;
}
bool IndefinitIndexBase::toNull() const
{
assert(not virt());
//assert(not virt());
return true;
}
void IndefinitIndexBase::evalMajor()
{
assert(not virt());
//assert(not virt());
if(not master()){
mMajor->eval();
}
@ -120,13 +120,13 @@ namespace MultiArrayTools
bool IndefinitIndexBase::master()
{
assert(not virt());
//assert(not virt());
return mMajor == nullptr;
}
void IndefinitIndexBase::subOrd(IndefinitIndexBase* major)
{
assert(not virt());
//assert(not virt());
mMajor = major;
}
@ -140,31 +140,29 @@ namespace MultiArrayTools
template <class Index>
size_t IndexBase<Index>::max() const
{
assert(not virt());
//assert(not virt());
return mRange->size();
}
template <class Index>
bool IndexBase<Index>::toNull() const
{
assert(not virt());
//assert(not virt());
return mRange == nullptr;
}
template <class Index>
void IndexBase<Index>::assignRange(RangeBase<Index> const* range)
{
assert(not virt());
//assert(not virt());
if(toNull()){
mRange = range;
}
}
/*
template <class Index>
void IndexBase<Index>::eval()
{
CHECK;
setPos( evaluate(*dynamic_cast<Index const*>( this )) );
}*/
}
}

View file

@ -57,7 +57,7 @@ namespace MultiArrayTools
virtual void subOrd(IndefinitIndexBase* major);
virtual bool virt() const { return true; }
//virtual bool virt() const { return true; }
protected:
@ -85,7 +85,7 @@ namespace MultiArrayTools
virtual void assignRange(RangeBase<Index> const* range);
//virtual void eval() override;
virtual void eval() override;
virtual void copyPos(const Index& in) = 0;
protected:

View file

@ -486,12 +486,13 @@ namespace MultiArrayTools
PositionCopy<sizeof...(Indices)-1>::copyPos(*this, in);
}
/*
template <class... Indices>
void MultiIndex<Indices...>::eval()
{
IIB::setPos( evaluate( *this ) );
}
*/
/*
template <size_t N>
struct RangeAssigner

View file

@ -80,9 +80,8 @@ namespace MultiArrayTools
virtual void copyPos(const MultiIndex<Indices...>& in) override;
virtual void eval() override;
virtual bool virt() const override { return false; }
//virtual void eval() override;
//virtual bool virt() const override { return false; }
//virtual void assignRange(RangeBase<MultiIndex<Indices...> > const* range) override;
};

View file

@ -155,9 +155,11 @@ namespace MultiArrayTools
IIB::setPos(in.pos());
}
/*
template <typename U, RangeType TYPE>
void SingleIndex<U,TYPE>::eval()
{
IIB::setPos( evaluate( *this ) );
}
*/
}

View file

@ -50,9 +50,8 @@ namespace MultiArrayTools
virtual void copyPos(const SingleIndex& in) override;
virtual void eval() override;
virtual bool virt() const override { return false; }
//virtual void eval() override;
//virtual bool virt() const override { return false; }
protected:
virtual size_t evaluate(const SingleIndex& in) const override;

View file

@ -359,11 +359,11 @@ namespace {
auto i1 = i.template getIndex<0>();
auto i2 = i.template getIndex<1>();
auto i3 = i.template getIndex<2>();
CHECK;
Slice2d3dAny sl(ra);
CHECK;
sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
EXPECT_EQ(sl.size(), 6);
Slice2d3dAny sl2(rb);
sl2("alpha","beta") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 0, i3 = 1)];
EXPECT_EQ(sl2.size(), 12);
@ -377,13 +377,12 @@ namespace {
auto i3 = i.template getIndex<2>();
Slice2d3dAny sl(ra);
sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
CHECK;
auto j = sl.begin();
auto j1 = j.template getIndex<0>();
auto j2 = j.template getIndex<1>();
CHECK;
EXPECT_EQ(sl[j(j1 = 0, j2 = 0)], 9);
CHECK;
EXPECT_EQ(sl[j(j1 = 0, j2 = 1)], 54);
EXPECT_EQ(sl[j(j1 = 1, j2 = 0)], -10);