im com (cleaning up)

This commit is contained in:
Christian Zimmermann 2017-12-16 20:38:57 +01:00
parent e46abff94c
commit f38b675314
2 changed files with 33 additions and 33 deletions

View file

@ -101,7 +101,7 @@ namespace MultiArrayHelper
{ {
public: public:
DEFAULT_MEMBERS(Block); DEFAULT_MEMBERS(Block);
Block(const std::vector<T>& data, size_t begPos, size_t size, size_t stepSize); Block(const T* data, size_t begPos, size_t size, size_t stepSize);
BlockType type() const; BlockType type() const;
const T& operator[](size_t pos) const; const T& operator[](size_t pos) const;
@ -109,7 +109,7 @@ namespace MultiArrayHelper
size_t stepSize() const; size_t stepSize() const;
protected: protected:
const std::vector<T>* mData; const T* mData;
const T* mBegPtr; const T* mBegPtr;
size_t mStepSize; size_t mStepSize;
}; };
@ -119,7 +119,7 @@ namespace MultiArrayHelper
{ {
public: public:
DEFAULT_MEMBERS(MBlock); DEFAULT_MEMBERS(MBlock);
MBlock(std::vector<T>& data, size_t begPos, size_t size, size_t stepSize); MBlock(T* data, size_t begPos, size_t size, size_t stepSize);
template <class BlockClass> template <class BlockClass>
MBlock& operator=(const BlockClass& in); MBlock& operator=(const BlockClass& in);
@ -131,7 +131,7 @@ namespace MultiArrayHelper
size_t stepSize() const; size_t stepSize() const;
protected: protected:
std::vector<T>* mData; T* mData;
T* mBegPtr; T* mBegPtr;
size_t mStepSize; size_t mStepSize;
}; };
@ -229,11 +229,11 @@ namespace MultiArrayHelper
*************/ *************/
template <typename T> template <typename T>
Block<T>::Block(const std::vector<T>& data, Block<T>::Block(const T* data,
size_t begPos, size_t size, size_t stepSize) : size_t begPos, size_t size, size_t stepSize) :
BlockBase<T>(size), BlockBase<T>(size),
mData(&data), mData(data),
mBegPtr(data.data() + begPos), mBegPtr(data + begPos),
mStepSize(stepSize) {} mStepSize(stepSize) {}
template <typename T> template <typename T>
@ -253,7 +253,7 @@ namespace MultiArrayHelper
template <typename T> template <typename T>
Block<T>& Block<T>::set(size_t npos) Block<T>& Block<T>::set(size_t npos)
{ {
mBegPtr = &(*mData)[npos]; mBegPtr = mData + npos;
return *this; return *this;
} }
@ -268,11 +268,11 @@ namespace MultiArrayHelper
**************/ **************/
template <typename T> template <typename T>
MBlock<T>::MBlock(std::vector<T>& data, MBlock<T>::MBlock(T* data,
size_t begPos, size_t size, size_t stepSize) : size_t begPos, size_t size, size_t stepSize) :
MutableBlockBase<T>(size), MutableBlockBase<T>(size),
mData(&data), mData(data),
mBegPtr(data.data() + begPos), mBegPtr(data + begPos),
mStepSize(stepSize) {} mStepSize(stepSize) {}
template <typename T> template <typename T>
@ -309,7 +309,7 @@ namespace MultiArrayHelper
template <typename T> template <typename T>
MBlock<T>& MBlock<T>::set(size_t npos) MBlock<T>& MBlock<T>::set(size_t npos)
{ {
mBegPtr = &(*mData)[npos]; mBegPtr = mData + npos;
return *this; return *this;
} }

View file

@ -43,10 +43,10 @@ namespace MultiArrayTools
bool first, size_t higherStepSize = 1); bool first, size_t higherStepSize = 1);
template <typename T> template <typename T>
std::shared_ptr<Block<T> > makeBlock(const std::vector<T>& vec, size_t stepSize, size_t blockSize); Block<T> makeBlock(const T* vec, size_t stepSize, size_t blockSize);
template <typename T> template <typename T>
std::shared_ptr<MBlock<T> > makeBlock(std::vector<T>& vec, size_t stepSize, size_t blockSize); MBlock<T> makeBlock(T* vec, size_t stepSize, size_t blockSize);
size_t getBTNum(const std::vector<BTSS>& mp, BlockType bt); size_t getBTNum(const std::vector<BTSS>& mp, BlockType bt);
@ -113,7 +113,7 @@ namespace MultiArrayTools
OpClass const& mSecond; OpClass const& mSecond;
MutableMultiArrayBase<T,Ranges...>& mArrayRef; MutableMultiArrayBase<T,Ranges...>& mArrayRef;
std::shared_ptr<IndexType> mIndex; std::shared_ptr<IndexType> mIndex;
mutable std::shared_ptr<MBlock<T> > mBlockPtr; mutable MBlock<T> mBlock;
}; };
@ -141,7 +141,7 @@ namespace MultiArrayTools
MultiArrayBase<T,Ranges...> const& mArrayRef; MultiArrayBase<T,Ranges...> const& mArrayRef;
std::shared_ptr<IndexType> mIndex; std::shared_ptr<IndexType> mIndex;
mutable std::shared_ptr<Block<T> > mBlockPtr; mutable Block<T> mBlock;
}; };
template <typename T, class... Ranges> template <typename T, class... Ranges>
@ -172,7 +172,7 @@ namespace MultiArrayTools
MutableMultiArrayBase<T,Ranges...>& mArrayRef; MutableMultiArrayBase<T,Ranges...>& mArrayRef;
std::shared_ptr<IndexType> mIndex; std::shared_ptr<IndexType> mIndex;
mutable std::shared_ptr<MBlock<T> > mBlockPtr; mutable MBlock<T> mBlock;
}; };
template <typename T, class OpFunction, class... Ops> template <typename T, class OpFunction, class... Ops>
@ -283,15 +283,15 @@ namespace MultiArrayTools
} }
template <typename T> template <typename T>
std::shared_ptr<Block<T> > makeBlock(const std::vector<T>& vec, size_t stepSize, size_t blockSize) Block<T> makeBlock(const T* vec, size_t stepSize, size_t blockSize)
{ {
return std::make_shared<Block<T> >(vec, 0, blockSize, stepSize); return Block<T>(vec, 0, blockSize, stepSize);
} }
template <typename T> template <typename T>
std::shared_ptr<MBlock<T> > makeBlock(std::vector<T>& vec, size_t stepSize, size_t blockSize) MBlock<T> makeBlock(T* vec, size_t stepSize, size_t blockSize)
{ {
return std::make_shared<MBlock<T> >(vec, 0, blockSize, stepSize); return MBlock<T>(vec, 0, blockSize, stepSize);
} }
size_t getBTNum(const std::vector<BTSS>& mp, BlockType bt) size_t getBTNum(const std::vector<BTSS>& mp, BlockType bt)
@ -426,28 +426,28 @@ namespace MultiArrayTools
MBlock<T>& OperationMaster<T,OpClass,Ranges...>::get() MBlock<T>& OperationMaster<T,OpClass,Ranges...>::get()
{ {
block(); block();
return *mBlockPtr; return mBlock;
} }
template <typename T, class OpClass, class... Ranges> template <typename T, class OpClass, class... Ranges>
const Block<T>& OperationMaster<T,OpClass,Ranges...>::get() const const Block<T>& OperationMaster<T,OpClass,Ranges...>::get() const
{ {
block(); block();
return *mBlockPtr; return mBlock;
} }
template <typename T, class OpClass, class... Ranges> template <typename T, class OpClass, class... Ranges>
std::vector<BTSS> OperationMaster<T,OpClass,Ranges...>::block(const std::shared_ptr<VIWB> blockIndex) const std::vector<BTSS> OperationMaster<T,OpClass,Ranges...>::block(const std::shared_ptr<VIWB> blockIndex) const
{ {
std::vector<BTSS> btv(1, getBlockType( make_viwb( mIndex ), blockIndex, true) ); std::vector<BTSS> btv(1, getBlockType( make_viwb( mIndex ), blockIndex, true) );
mBlockPtr = makeBlock(mArrayRef.datav(), btv[0].second, blockIndex->max()); mBlock = makeBlock(mArrayRef.data(), btv[0].second, blockIndex->max());
return btv; return btv;
} }
template <typename T, class OpClass, class... Ranges> template <typename T, class OpClass, class... Ranges>
const OperationMaster<T,OpClass,Ranges...>& OperationMaster<T,OpClass,Ranges...>::block() const const OperationMaster<T,OpClass,Ranges...>& OperationMaster<T,OpClass,Ranges...>::block() const
{ {
mBlockPtr->set( mIndex->pos() ); mBlock.set( mIndex->pos() );
return *this; return *this;
} }
@ -469,21 +469,21 @@ namespace MultiArrayTools
const Block<T>& ConstOperationRoot<T,Ranges...>::get() const const Block<T>& ConstOperationRoot<T,Ranges...>::get() const
{ {
block(); block();
return *mBlockPtr; return mBlock;
} }
template <typename T, class... Ranges> template <typename T, class... Ranges>
std::vector<BTSS> ConstOperationRoot<T,Ranges...>::block(const std::shared_ptr<VIWB> blockIndex) const std::vector<BTSS> ConstOperationRoot<T,Ranges...>::block(const std::shared_ptr<VIWB> blockIndex) const
{ {
std::vector<BTSS> btv(1, getBlockType( make_viwb( mIndex ), blockIndex, true) ); std::vector<BTSS> btv(1, getBlockType( make_viwb( mIndex ), blockIndex, true) );
mBlockPtr = makeBlock(mArrayRef.datav(), btv[0].second, blockIndex->max()); mBlock = makeBlock(mArrayRef.data(), btv[0].second, blockIndex->max());
return btv; return btv;
} }
template <typename T, class... Ranges> template <typename T, class... Ranges>
const ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::block() const const ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::block() const
{ {
mBlockPtr->set( (*mIndex)().pos() ); mBlock.set( (*mIndex)().pos() );
return *this; return *this;
} }
@ -512,28 +512,28 @@ namespace MultiArrayTools
const MBlock<T>& OperationRoot<T,Ranges...>::get() const const MBlock<T>& OperationRoot<T,Ranges...>::get() const
{ {
block(); block();
return *mBlockPtr; return mBlock;
} }
template <typename T, class... Ranges> template <typename T, class... Ranges>
MBlock<T>& OperationRoot<T,Ranges...>::get() MBlock<T>& OperationRoot<T,Ranges...>::get()
{ {
block(); block();
return *mBlockPtr; return mBlock;
} }
template <typename T, class... Ranges> template <typename T, class... Ranges>
std::vector<BTSS> OperationRoot<T,Ranges...>::block(const std::shared_ptr<VIWB> blockIndex) const std::vector<BTSS> OperationRoot<T,Ranges...>::block(const std::shared_ptr<VIWB> blockIndex) const
{ {
std::vector<BTSS> btv(1, getBlockType( make_viwb( mIndex ), blockIndex, true) ); std::vector<BTSS> btv(1, getBlockType( make_viwb( mIndex ), blockIndex, true) );
mBlockPtr = makeBlock(mArrayRef.datav(), btv[0].second, blockIndex->max()); mBlock = makeBlock(mArrayRef.data(), btv[0].second, blockIndex->max());
return btv; return btv;
} }
template <typename T, class... Ranges> template <typename T, class... Ranges>
const OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::block() const const OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::block() const
{ {
mBlockPtr->set( (*mIndex)().pos() ); mBlock.set( (*mIndex)().pos() );
return *this; return *this;
} }
@ -564,7 +564,7 @@ namespace MultiArrayTools
template <typename T, class OpFunction, class... Ops> template <typename T, class OpFunction, class... Ops>
const Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::block() const const Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::block() const
{ {
//mBlockPtr->set( mIndex->pos() ); //mBlock.set( mIndex->pos() );
return *this; return *this;
} }