anonymous range: sreplace -> const; return new range instead
This commit is contained in:
parent
8048c573fa
commit
75ead6fdba
2 changed files with 11 additions and 6 deletions
|
@ -93,8 +93,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& orig() const;
|
const std::vector<std::shared_ptr<RangeBase> >& orig() const;
|
||||||
|
|
||||||
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
std::shared_ptr<AnonymousRange> sreplace(const std::shared_ptr<RangeBase> in, size_t num) const;
|
||||||
void sreplace(const std::vector<std::shared_ptr<RangeBase>>& in, size_t num);
|
std::shared_ptr<AnonymousRange> sreplace(const std::vector<std::shared_ptr<RangeBase>>& in, size_t num) const;
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
|
|
@ -159,13 +159,16 @@ namespace MultiArrayTools
|
||||||
return mOrig.at(num);
|
return mOrig.at(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnonymousRange::sreplace(const std::shared_ptr<RangeBase> in, size_t num)
|
std::shared_ptr<AnonymousRange> AnonymousRange::sreplace(const std::shared_ptr<RangeBase> in, size_t num) const
|
||||||
{
|
{
|
||||||
assert(mOrig[num]->size() == in->size());
|
assert(mOrig[num]->size() == in->size());
|
||||||
mOrig[num] = in;
|
auto tmp = mOrig;
|
||||||
|
tmp[num] = in;
|
||||||
|
AnonymousRangeFactory arf(tmp);
|
||||||
|
return std::dynamic_pointer_cast<AnonymousRange>(arf.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnonymousRange::sreplace(const std::vector<std::shared_ptr<RangeBase>>& in, size_t num)
|
std::shared_ptr<AnonymousRange> AnonymousRange::sreplace(const std::vector<std::shared_ptr<RangeBase>>& in, size_t num) const
|
||||||
{
|
{
|
||||||
size_t nsize = 1;
|
size_t nsize = 1;
|
||||||
for(auto& x: in){
|
for(auto& x: in){
|
||||||
|
@ -183,7 +186,9 @@ namespace MultiArrayTools
|
||||||
for(size_t i = num + 1 ; i < mOrig.size(); ++i){
|
for(size_t i = num + 1 ; i < mOrig.size(); ++i){
|
||||||
norig[in.size()+i-1] = mOrig[i];
|
norig[in.size()+i-1] = mOrig[i];
|
||||||
}
|
}
|
||||||
mOrig = std::move( norig );
|
//mOrig = std::move( norig );
|
||||||
|
AnonymousRangeFactory arf(norig);
|
||||||
|
return std::dynamic_pointer_cast<AnonymousRange>(arf.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& AnonymousRange::orig() const
|
const std::vector<std::shared_ptr<RangeBase> >& AnonymousRange::orig() const
|
||||||
|
|
Loading…
Reference in a new issue