From f38b6753140725565479069102639296869d0839 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Sat, 16 Dec 2017 20:38:57 +0100 Subject: [PATCH] im com (cleaning up) --- src/block.h | 24 ++++++++++----------- src/multi_array_operation.h | 42 ++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/block.h b/src/block.h index 00dd200..686ae5e 100644 --- a/src/block.h +++ b/src/block.h @@ -101,7 +101,7 @@ namespace MultiArrayHelper { public: DEFAULT_MEMBERS(Block); - Block(const std::vector& 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; const T& operator[](size_t pos) const; @@ -109,7 +109,7 @@ namespace MultiArrayHelper size_t stepSize() const; protected: - const std::vector* mData; + const T* mData; const T* mBegPtr; size_t mStepSize; }; @@ -119,7 +119,7 @@ namespace MultiArrayHelper { public: DEFAULT_MEMBERS(MBlock); - MBlock(std::vector& data, size_t begPos, size_t size, size_t stepSize); + MBlock(T* data, size_t begPos, size_t size, size_t stepSize); template MBlock& operator=(const BlockClass& in); @@ -131,7 +131,7 @@ namespace MultiArrayHelper size_t stepSize() const; protected: - std::vector* mData; + T* mData; T* mBegPtr; size_t mStepSize; }; @@ -229,11 +229,11 @@ namespace MultiArrayHelper *************/ template - Block::Block(const std::vector& data, + Block::Block(const T* data, size_t begPos, size_t size, size_t stepSize) : BlockBase(size), - mData(&data), - mBegPtr(data.data() + begPos), + mData(data), + mBegPtr(data + begPos), mStepSize(stepSize) {} template @@ -253,7 +253,7 @@ namespace MultiArrayHelper template Block& Block::set(size_t npos) { - mBegPtr = &(*mData)[npos]; + mBegPtr = mData + npos; return *this; } @@ -268,11 +268,11 @@ namespace MultiArrayHelper **************/ template - MBlock::MBlock(std::vector& data, + MBlock::MBlock(T* data, size_t begPos, size_t size, size_t stepSize) : MutableBlockBase(size), - mData(&data), - mBegPtr(data.data() + begPos), + mData(data), + mBegPtr(data + begPos), mStepSize(stepSize) {} template @@ -309,7 +309,7 @@ namespace MultiArrayHelper template MBlock& MBlock::set(size_t npos) { - mBegPtr = &(*mData)[npos]; + mBegPtr = mData + npos; return *this; } diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index 2a6e0ef..314258c 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -43,10 +43,10 @@ namespace MultiArrayTools bool first, size_t higherStepSize = 1); template - std::shared_ptr > makeBlock(const std::vector& vec, size_t stepSize, size_t blockSize); + Block makeBlock(const T* vec, size_t stepSize, size_t blockSize); template - std::shared_ptr > makeBlock(std::vector& vec, size_t stepSize, size_t blockSize); + MBlock makeBlock(T* vec, size_t stepSize, size_t blockSize); size_t getBTNum(const std::vector& mp, BlockType bt); @@ -113,7 +113,7 @@ namespace MultiArrayTools OpClass const& mSecond; MutableMultiArrayBase& mArrayRef; std::shared_ptr mIndex; - mutable std::shared_ptr > mBlockPtr; + mutable MBlock mBlock; }; @@ -141,7 +141,7 @@ namespace MultiArrayTools MultiArrayBase const& mArrayRef; std::shared_ptr mIndex; - mutable std::shared_ptr > mBlockPtr; + mutable Block mBlock; }; template @@ -172,7 +172,7 @@ namespace MultiArrayTools MutableMultiArrayBase& mArrayRef; std::shared_ptr mIndex; - mutable std::shared_ptr > mBlockPtr; + mutable MBlock mBlock; }; template @@ -283,15 +283,15 @@ namespace MultiArrayTools } template - std::shared_ptr > makeBlock(const std::vector& vec, size_t stepSize, size_t blockSize) + Block makeBlock(const T* vec, size_t stepSize, size_t blockSize) { - return std::make_shared >(vec, 0, blockSize, stepSize); + return Block(vec, 0, blockSize, stepSize); } template - std::shared_ptr > makeBlock(std::vector& vec, size_t stepSize, size_t blockSize) + MBlock makeBlock(T* vec, size_t stepSize, size_t blockSize) { - return std::make_shared >(vec, 0, blockSize, stepSize); + return MBlock(vec, 0, blockSize, stepSize); } size_t getBTNum(const std::vector& mp, BlockType bt) @@ -426,28 +426,28 @@ namespace MultiArrayTools MBlock& OperationMaster::get() { block(); - return *mBlockPtr; + return mBlock; } template const Block& OperationMaster::get() const { block(); - return *mBlockPtr; + return mBlock; } template std::vector OperationMaster::block(const std::shared_ptr blockIndex) const { std::vector 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; } template const OperationMaster& OperationMaster::block() const { - mBlockPtr->set( mIndex->pos() ); + mBlock.set( mIndex->pos() ); return *this; } @@ -469,21 +469,21 @@ namespace MultiArrayTools const Block& ConstOperationRoot::get() const { block(); - return *mBlockPtr; + return mBlock; } template std::vector ConstOperationRoot::block(const std::shared_ptr blockIndex) const { std::vector 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; } template const ConstOperationRoot& ConstOperationRoot::block() const { - mBlockPtr->set( (*mIndex)().pos() ); + mBlock.set( (*mIndex)().pos() ); return *this; } @@ -512,28 +512,28 @@ namespace MultiArrayTools const MBlock& OperationRoot::get() const { block(); - return *mBlockPtr; + return mBlock; } template MBlock& OperationRoot::get() { block(); - return *mBlockPtr; + return mBlock; } template std::vector OperationRoot::block(const std::shared_ptr blockIndex) const { std::vector 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; } template const OperationRoot& OperationRoot::block() const { - mBlockPtr->set( (*mIndex)().pos() ); + mBlock.set( (*mIndex)().pos() ); return *this; } @@ -564,7 +564,7 @@ namespace MultiArrayTools template const Operation& Operation::block() const { - //mBlockPtr->set( mIndex->pos() ); + //mBlock.set( mIndex->pos() ); return *this; }