Kaydet (Commit) 51f73f35 authored tarafından Kohei Yoshida's avatar Kohei Yoshida Kaydeden (comit) Kohei Yoshida

Update mdds to 1.4.1.

The largest change in 1.4.x relevant to the calc code is that the
multi_type_matrix::walk() methods now take a copy of the function
object rather than a reference, to allow for it to take an inline
lambda function.  Instead, it does return a instance of the input
function object, similar to how std::for_each() behaves.

In case the function object contains a large data member, try to
make it a moveable so that it will get moved rather than copied
when going through one of the walk() methods.

Change-Id: Ifd08fc4a2ed75039e5292a35ff08726e0126c77f
Reviewed-on: https://gerrit.libreoffice.org/59584
Tested-by: Jenkins
Reviewed-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
üst 5061663c
...@@ -166,8 +166,8 @@ export LXML_SHA256SUM := 940caef1ec7c78e0c34b0f6b94fe42d0f2022915ffc78643d28538a ...@@ -166,8 +166,8 @@ export LXML_SHA256SUM := 940caef1ec7c78e0c34b0f6b94fe42d0f2022915ffc78643d28538a
export LXML_TARBALL := lxml-4.1.1.tgz export LXML_TARBALL := lxml-4.1.1.tgz
export MARIADB_CONNECTOR_C_SHA256SUM := fd2f751dea049c1907735eb236aeace1d811d6a8218118b00bbaa9b84dc5cd60 export MARIADB_CONNECTOR_C_SHA256SUM := fd2f751dea049c1907735eb236aeace1d811d6a8218118b00bbaa9b84dc5cd60
export MARIADB_CONNECTOR_C_TARBALL := a233181e03d3c307668b4c722d881661-mariadb_client-2.0.0-src.tar.gz export MARIADB_CONNECTOR_C_TARBALL := a233181e03d3c307668b4c722d881661-mariadb_client-2.0.0-src.tar.gz
export MDDS_SHA256SUM := dcb8cd2425567a5a5ec164afea475bce57784bca3e352ad4cbdd3d1a7e08e5a1 export MDDS_SHA256SUM := 9ac690c37f5f06dc88551405d5daf9d9ad25edf65aae6325b59e905c2ba444c3
export MDDS_TARBALL := mdds-1.3.1.tar.bz2 export MDDS_TARBALL := mdds-1.4.1.tar.bz2
export MDNSRESPONDER_SHA256SUM := 4737cb51378377e11d0edb7bcdd1bec79cbdaa7b27ea09c13e3006e58f8d92c0 export MDNSRESPONDER_SHA256SUM := 4737cb51378377e11d0edb7bcdd1bec79cbdaa7b27ea09c13e3006e58f8d92c0
export MDNSRESPONDER_TARBALL := mDNSResponder-576.30.4.tar.gz export MDNSRESPONDER_TARBALL := mDNSResponder-576.30.4.tar.gz
export MSPUB_SHA256SUM := ef36c1a1aabb2ba3b0bedaaafe717bf4480be2ba8de6f3894be5fd3702b013ba export MSPUB_SHA256SUM := ef36c1a1aabb2ba3b0bedaaafe717bf4480be2ba8de6f3894be5fd3702b013ba
......
...@@ -13,13 +13,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,mdds,$(MDDS_TARBALL))) ...@@ -13,13 +13,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,mdds,$(MDDS_TARBALL)))
$(eval $(call gb_UnpackedTarball_set_patchlevel,mdds,0)) $(eval $(call gb_UnpackedTarball_set_patchlevel,mdds,0))
# c++17.patch upstreamed as <https://gitlab.com/mdds/mdds/merge_requests/11> "Remove some
# unnecessary uses of obsolete std::unary_function";
# gcc9.patch upstreamed at <https://gitlab.com/mdds/mdds/merge_requests/14> "Remove unnecessary
# user-provided special members that cause -Wdeprecated-copy":
$(eval $(call gb_UnpackedTarball_add_patches,mdds,\ $(eval $(call gb_UnpackedTarball_add_patches,mdds,\
external/mdds/c++17.patch \
external/mdds/gcc9.patch \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
--- include/mdds/multi_type_matrix.hpp
+++ include/mdds/multi_type_matrix.hpp
@@ -149,7 +149,7 @@
private:
template<typename _Func>
- struct walk_func : std::unary_function<typename store_type::const_iterator::value_type, void>
+ struct walk_func
{
_Func& m_func;
walk_func(_Func& func) : m_func(func) {}
--- include/mdds/multi_type_vector.hpp
+++ include/mdds/multi_type_vector.hpp
@@ -139,7 +139,7 @@
block& operator=(block);
};
- struct element_block_deleter : public std::unary_function<void, const element_block_type*>
+ struct element_block_deleter
{
void operator() (const element_block_type* p)
{
--- include/mdds/multi_type_vector_itr.hpp
+++ include/mdds/multi_type_vector_itr.hpp
@@ -54,9 +54,6 @@
iterator_value_node(size_type start_pos, size_type block_index) :
type(mdds::mtv::element_type_empty), position(start_pos), size(0), data(nullptr), __private_data(block_index) {}
- iterator_value_node(const iterator_value_node& other) :
- type(other.type), position(other.position), size(other.size), data(other.data), __private_data(other.__private_data) {}
-
void swap(iterator_value_node& other)
{
std::swap(type, other.type);
@@ -272,9 +269,6 @@
size_type start_pos, size_type block_index) :
common_base(pos, end, start_pos, block_index) {}
- iterator_base(const iterator_base& other) :
- common_base(other) {}
-
value_type& operator*()
{
return m_cur_node;
@@ -345,9 +339,6 @@
size_type start_pos, size_type block_index) :
common_base(pos, end, start_pos, block_index) {}
- const_iterator_base(const const_iterator_base& other) :
- common_base(other) {}
-
/**
* Take the non-const iterator counterpart to create a const iterator.
*/
--- include/mdds/multi_type_vector_types.hpp
+++ include/mdds/multi_type_vector_types.hpp
@@ -90,7 +90,6 @@
protected:
element_t type;
base_element_block(element_t _t) : type(_t) {}
- ~base_element_block() {}
};
template<typename _Self, element_t _TypeId, typename _Data>
...@@ -161,6 +161,12 @@ public: ...@@ -161,6 +161,12 @@ public:
maNewMatValues.reserve(nRow*nCol); maNewMatValues.reserve(nRow*nCol);
} }
CompareMatrixElemFunc( const CompareMatrixElemFunc& ) = delete;
CompareMatrixElemFunc& operator= ( const CompareMatrixElemFunc& ) = delete;
CompareMatrixElemFunc( CompareMatrixElemFunc&& ) = default;
CompareMatrixElemFunc& operator= ( CompareMatrixElemFunc&& ) = default;
void operator() (const MatrixImplType::element_block_node_type& node) void operator() (const MatrixImplType::element_block_node_type& node)
{ {
switch (node.type) switch (node.type)
...@@ -980,7 +986,7 @@ void ScMatrixImpl::CompareEqual() ...@@ -980,7 +986,7 @@ void ScMatrixImpl::CompareEqual()
{ {
MatrixImplType::size_pair_type aSize = maMat.size(); MatrixImplType::size_pair_type aSize = maMat.size();
CompareMatrixElemFunc<ElemEqualZero> aFunc(aSize.row, aSize.column); CompareMatrixElemFunc<ElemEqualZero> aFunc(aSize.row, aSize.column);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
aFunc.swap(maMat); aFunc.swap(maMat);
} }
...@@ -988,7 +994,7 @@ void ScMatrixImpl::CompareNotEqual() ...@@ -988,7 +994,7 @@ void ScMatrixImpl::CompareNotEqual()
{ {
MatrixImplType::size_pair_type aSize = maMat.size(); MatrixImplType::size_pair_type aSize = maMat.size();
CompareMatrixElemFunc<ElemNotEqualZero> aFunc(aSize.row, aSize.column); CompareMatrixElemFunc<ElemNotEqualZero> aFunc(aSize.row, aSize.column);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
aFunc.swap(maMat); aFunc.swap(maMat);
} }
...@@ -996,7 +1002,7 @@ void ScMatrixImpl::CompareLess() ...@@ -996,7 +1002,7 @@ void ScMatrixImpl::CompareLess()
{ {
MatrixImplType::size_pair_type aSize = maMat.size(); MatrixImplType::size_pair_type aSize = maMat.size();
CompareMatrixElemFunc<ElemLessZero> aFunc(aSize.row, aSize.column); CompareMatrixElemFunc<ElemLessZero> aFunc(aSize.row, aSize.column);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
aFunc.swap(maMat); aFunc.swap(maMat);
} }
...@@ -1004,7 +1010,7 @@ void ScMatrixImpl::CompareGreater() ...@@ -1004,7 +1010,7 @@ void ScMatrixImpl::CompareGreater()
{ {
MatrixImplType::size_pair_type aSize = maMat.size(); MatrixImplType::size_pair_type aSize = maMat.size();
CompareMatrixElemFunc<ElemGreaterZero> aFunc(aSize.row, aSize.column); CompareMatrixElemFunc<ElemGreaterZero> aFunc(aSize.row, aSize.column);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
aFunc.swap(maMat); aFunc.swap(maMat);
} }
...@@ -1012,7 +1018,7 @@ void ScMatrixImpl::CompareLessEqual() ...@@ -1012,7 +1018,7 @@ void ScMatrixImpl::CompareLessEqual()
{ {
MatrixImplType::size_pair_type aSize = maMat.size(); MatrixImplType::size_pair_type aSize = maMat.size();
CompareMatrixElemFunc<ElemLessEqualZero> aFunc(aSize.row, aSize.column); CompareMatrixElemFunc<ElemLessEqualZero> aFunc(aSize.row, aSize.column);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
aFunc.swap(maMat); aFunc.swap(maMat);
} }
...@@ -1020,7 +1026,7 @@ void ScMatrixImpl::CompareGreaterEqual() ...@@ -1020,7 +1026,7 @@ void ScMatrixImpl::CompareGreaterEqual()
{ {
MatrixImplType::size_pair_type aSize = maMat.size(); MatrixImplType::size_pair_type aSize = maMat.size();
CompareMatrixElemFunc<ElemGreaterEqualZero> aFunc(aSize.row, aSize.column); CompareMatrixElemFunc<ElemGreaterEqualZero> aFunc(aSize.row, aSize.column);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
aFunc.swap(maMat); aFunc.swap(maMat);
} }
...@@ -1175,20 +1181,34 @@ public: ...@@ -1175,20 +1181,34 @@ public:
template<typename Op> template<typename Op>
class WalkElementBlocksMultipleValues class WalkElementBlocksMultipleValues
{ {
const std::vector<std::unique_ptr<Op>>& maOp; const std::vector<std::unique_ptr<Op>>* mpOp;
std::vector<ScMatrix::IterateResult> maRes; std::vector<ScMatrix::IterateResult> maRes;
bool mbFirst:1; bool mbFirst:1;
public: public:
WalkElementBlocksMultipleValues(const std::vector<std::unique_ptr<Op>>& aOp) : WalkElementBlocksMultipleValues(const std::vector<std::unique_ptr<Op>>& aOp) :
maOp(aOp), mbFirst(true) mpOp(&aOp), mbFirst(true)
{ {
for (const auto& rpOp : maOp) for (const auto& rpOp : *mpOp)
{ {
maRes.emplace_back(rpOp->mInitVal, rpOp->mInitVal, 0); maRes.emplace_back(rpOp->mInitVal, rpOp->mInitVal, 0);
} }
maRes.emplace_back(0.0, 0.0, 0); // count maRes.emplace_back(0.0, 0.0, 0); // count
} }
WalkElementBlocksMultipleValues( const WalkElementBlocksMultipleValues& ) = delete;
WalkElementBlocksMultipleValues& operator= ( const WalkElementBlocksMultipleValues& ) = delete;
WalkElementBlocksMultipleValues( WalkElementBlocksMultipleValues&& r ) :
mpOp(r.mpOp), maRes(std::move(r.maRes)), mbFirst(r.mbFirst) {}
WalkElementBlocksMultipleValues& operator= ( WalkElementBlocksMultipleValues&& r )
{
mpOp = r.mpOp;
maRes = std::move(r.maRes);
mbFirst = r.mbFirst;
return *this;
}
const std::vector<ScMatrix::IterateResult>& getResult() const { return maRes; } const std::vector<ScMatrix::IterateResult>& getResult() const { return maRes; }
void operator() (const MatrixImplType::element_block_node_type& node) void operator() (const MatrixImplType::element_block_node_type& node)
...@@ -1205,17 +1225,17 @@ public: ...@@ -1205,17 +1225,17 @@ public:
{ {
if (mbFirst) if (mbFirst)
{ {
for (auto i = 0u; i < maOp.size(); ++i) for (auto i = 0u; i < mpOp->size(); ++i)
{ {
(*maOp[i])(maRes[i].mfFirst, *it); (*(*mpOp)[i])(maRes[i].mfFirst, *it);
} }
mbFirst = false; mbFirst = false;
} }
else else
{ {
for (auto i = 0u; i < maOp.size(); ++i) for (auto i = 0u; i < mpOp->size(); ++i)
{ {
(*maOp[i])(maRes[i].mfRest, *it); (*(*mpOp)[i])(maRes[i].mfRest, *it);
} }
} }
} }
...@@ -1232,17 +1252,17 @@ public: ...@@ -1232,17 +1252,17 @@ public:
{ {
if (mbFirst) if (mbFirst)
{ {
for (auto i = 0u; i < maOp.size(); ++i) for (auto i = 0u; i < mpOp->size(); ++i)
{ {
(*maOp[i])(maRes[i].mfFirst, *it); (*(*mpOp)[i])(maRes[i].mfFirst, *it);
} }
mbFirst = false; mbFirst = false;
} }
else else
{ {
for (auto i = 0u; i < maOp.size(); ++i) for (auto i = 0u; i < mpOp->size(); ++i)
{ {
(*maOp[i])(maRes[i].mfRest, *it); (*(*mpOp)[i])(maRes[i].mfRest, *it);
} }
} }
} }
...@@ -1307,8 +1327,8 @@ template<typename Type> ...@@ -1307,8 +1327,8 @@ template<typename Type>
class WalkAndMatchElements class WalkAndMatchElements
{ {
Type maMatchValue; Type maMatchValue;
const size_t mnStartIndex; size_t mnStartIndex;
const size_t mnStopIndex; size_t mnStopIndex;
size_t mnResult; size_t mnResult;
size_t mnIndex; size_t mnIndex;
...@@ -1666,6 +1686,24 @@ public: ...@@ -1666,6 +1686,24 @@ public:
maResValues.reserve(nResSize); maResValues.reserve(nResSize);
} }
CompareMatrixFunc( const CompareMatrixFunc& ) = delete;
CompareMatrixFunc& operator= ( const CompareMatrixFunc& ) = delete;
CompareMatrixFunc( CompareMatrixFunc&& r ) :
mrComp(r.mrComp),
mnMatPos(r.mnMatPos),
mpOptions(r.mpOptions),
maResValues(std::move(r.maResValues)) {}
CompareMatrixFunc& operator= ( CompareMatrixFunc&& r )
{
mrComp = r.mrComp;
mnMatPos = r.mnMatPos;
mpOptions = r.mpOptions;
maResValues = std::move(r.maResValues);
return *this;
}
void operator() (const MatrixImplType::element_block_node_type& node) void operator() (const MatrixImplType::element_block_node_type& node)
{ {
sc::Compare::Cell& rCell = mrComp.maCells[mnMatPos]; sc::Compare::Cell& rCell = mrComp.maCells[mnMatPos];
...@@ -1774,6 +1812,24 @@ public: ...@@ -1774,6 +1812,24 @@ public:
maResValues.reserve(nResSize); maResValues.reserve(nResSize);
} }
CompareMatrixToNumericFunc( const CompareMatrixToNumericFunc& ) = delete;
CompareMatrixToNumericFunc& operator= ( const CompareMatrixToNumericFunc& ) = delete;
CompareMatrixToNumericFunc( CompareMatrixToNumericFunc&& r ) :
mrComp(r.mrComp),
mfRightValue(r.mfRightValue),
mpOptions(r.mpOptions),
maResValues(std::move(r.maResValues)) {}
CompareMatrixToNumericFunc& operator= ( CompareMatrixToNumericFunc&& r )
{
mrComp = r.mrComp;
mfRightValue = r.mfRightValue;
mpOptions = r.mpOptions;
maResValues = std::move(r.maResValues);
return *this;
}
void operator() (const MatrixImplType::element_block_node_type& node) void operator() (const MatrixImplType::element_block_node_type& node)
{ {
sc::Compare::Cell& rCell = mrComp.maCells[0]; sc::Compare::Cell& rCell = mrComp.maCells[0];
...@@ -1837,6 +1893,17 @@ class ToDoubleArray ...@@ -1837,6 +1893,17 @@ class ToDoubleArray
double mfNaN; double mfNaN;
bool mbEmptyAsZero; bool mbEmptyAsZero;
void moveArray( ToDoubleArray& r )
{
// Re-create the iterator from the new array after the array has been
// moved, to ensure that the iterator points to a valid array
// position.
size_t n = std::distance(r.maArray.begin(), r.miPos);
maArray = std::move(r.maArray);
miPos = maArray.begin();
std::advance(miPos, n);
}
public: public:
ToDoubleArray( size_t nSize, bool bEmptyAsZero ) : ToDoubleArray( size_t nSize, bool bEmptyAsZero ) :
maArray(nSize, 0.0), miPos(maArray.begin()), mbEmptyAsZero(bEmptyAsZero) maArray(nSize, 0.0), miPos(maArray.begin()), mbEmptyAsZero(bEmptyAsZero)
...@@ -1844,6 +1911,23 @@ public: ...@@ -1844,6 +1911,23 @@ public:
mfNaN = CreateDoubleError( FormulaError::ElementNaN); mfNaN = CreateDoubleError( FormulaError::ElementNaN);
} }
ToDoubleArray( const ToDoubleArray& ) = delete;
ToDoubleArray& operator= ( const ToDoubleArray& ) = delete;
ToDoubleArray( ToDoubleArray&& r ) :
mfNaN(r.mfNaN), mbEmptyAsZero(r.mbEmptyAsZero)
{
moveArray(r);
}
ToDoubleArray& operator= ( ToDoubleArray&& r )
{
mfNaN = r.mfNaN;
mbEmptyAsZero = r.mbEmptyAsZero;
moveArray(r);
return *this;
}
void operator() (const MatrixImplType::element_block_node_type& node) void operator() (const MatrixImplType::element_block_node_type& node)
{ {
using namespace mdds::mtv; using namespace mdds::mtv;
...@@ -1914,6 +1998,12 @@ public: ...@@ -1914,6 +1998,12 @@ public:
mfNaN = CreateDoubleError( FormulaError::ElementNaN); mfNaN = CreateDoubleError( FormulaError::ElementNaN);
} }
MergeDoubleArrayFunc( const MergeDoubleArrayFunc& ) = delete;
MergeDoubleArrayFunc& operator= ( const MergeDoubleArrayFunc& ) = delete;
MergeDoubleArrayFunc( MergeDoubleArrayFunc&& ) = default;
MergeDoubleArrayFunc& operator= ( MergeDoubleArrayFunc&& ) = default;
void operator() (const MatrixImplType::element_block_node_type& node) void operator() (const MatrixImplType::element_block_node_type& node)
{ {
using namespace mdds::mtv; using namespace mdds::mtv;
...@@ -1979,7 +2069,7 @@ template<typename TOp> ...@@ -1979,7 +2069,7 @@ template<typename TOp>
ScMatrix::IterateResult GetValueWithCount(bool bTextAsZero, const MatrixImplType& maMat) ScMatrix::IterateResult GetValueWithCount(bool bTextAsZero, const MatrixImplType& maMat)
{ {
WalkElementBlocks<TOp> aFunc(bTextAsZero); WalkElementBlocks<TOp> aFunc(bTextAsZero);
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getResult(); return aFunc.getResult();
} }
...@@ -2003,49 +2093,49 @@ ScMatrix::IterateResult ScMatrixImpl::Product(bool bTextAsZero) const ...@@ -2003,49 +2093,49 @@ ScMatrix::IterateResult ScMatrixImpl::Product(bool bTextAsZero) const
size_t ScMatrixImpl::Count(bool bCountStrings, bool bCountErrors) const size_t ScMatrixImpl::Count(bool bCountStrings, bool bCountErrors) const
{ {
CountElements aFunc(bCountStrings, bCountErrors); CountElements aFunc(bCountStrings, bCountErrors);
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getCount(); return aFunc.getCount();
} }
size_t ScMatrixImpl::MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const size_t ScMatrixImpl::MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const
{ {
WalkAndMatchElements<double> aFunc(fValue, maMat.size(), nCol1, nCol2); WalkAndMatchElements<double> aFunc(fValue, maMat.size(), nCol1, nCol2);
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getMatching(); return aFunc.getMatching();
} }
size_t ScMatrixImpl::MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const size_t ScMatrixImpl::MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const
{ {
WalkAndMatchElements<svl::SharedString> aFunc(rStr, maMat.size(), nCol1, nCol2); WalkAndMatchElements<svl::SharedString> aFunc(rStr, maMat.size(), nCol1, nCol2);
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getMatching(); return aFunc.getMatching();
} }
double ScMatrixImpl::GetMaxValue( bool bTextAsZero ) const double ScMatrixImpl::GetMaxValue( bool bTextAsZero ) const
{ {
CalcMaxMinValue<MaxOp> aFunc(bTextAsZero); CalcMaxMinValue<MaxOp> aFunc(bTextAsZero);
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getValue(); return aFunc.getValue();
} }
double ScMatrixImpl::GetMinValue( bool bTextAsZero ) const double ScMatrixImpl::GetMinValue( bool bTextAsZero ) const
{ {
CalcMaxMinValue<MinOp> aFunc(bTextAsZero); CalcMaxMinValue<MinOp> aFunc(bTextAsZero);
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getValue(); return aFunc.getValue();
} }
double ScMatrixImpl::GetGcd() const double ScMatrixImpl::GetGcd() const
{ {
CalcGcdLcm<Gcd> aFunc; CalcGcdLcm<Gcd> aFunc;
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getResult(); return aFunc.getResult();
} }
double ScMatrixImpl::GetLcm() const double ScMatrixImpl::GetLcm() const
{ {
CalcGcdLcm<Lcm> aFunc; CalcGcdLcm<Lcm> aFunc;
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
return aFunc.getResult(); return aFunc.getResult();
} }
...@@ -2062,7 +2152,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix( ...@@ -2062,7 +2152,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix(
// function object that has much less branching for much better // function object that has much less branching for much better
// performance. // performance.
CompareMatrixToNumericFunc aFunc(nSize, rComp, rComp.maCells[1].mfValue, pOptions); CompareMatrixToNumericFunc aFunc(nSize, rComp, rComp.maCells[1].mfValue, pOptions);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
// We assume the result matrix has the same dimension as this matrix. // We assume the result matrix has the same dimension as this matrix.
const std::vector<double>& rResVal = aFunc.getValues(); const std::vector<double>& rResVal = aFunc.getValues();
...@@ -2074,7 +2164,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix( ...@@ -2074,7 +2164,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix(
} }
CompareMatrixFunc aFunc(nSize, rComp, nMatPos, pOptions); CompareMatrixFunc aFunc(nSize, rComp, nMatPos, pOptions);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
// We assume the result matrix has the same dimension as this matrix. // We assume the result matrix has the same dimension as this matrix.
const std::vector<double>& rResVal = aFunc.getValues(); const std::vector<double>& rResVal = aFunc.getValues();
...@@ -2088,7 +2178,7 @@ void ScMatrixImpl::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZer ...@@ -2088,7 +2178,7 @@ void ScMatrixImpl::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZer
{ {
MatrixImplType::size_pair_type aSize = maMat.size(); MatrixImplType::size_pair_type aSize = maMat.size();
ToDoubleArray aFunc(aSize.row*aSize.column, bEmptyAsZero); ToDoubleArray aFunc(aSize.row*aSize.column, bEmptyAsZero);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
aFunc.swap(rArray); aFunc.swap(rArray);
} }
...@@ -2104,7 +2194,7 @@ void ScMatrixImpl::MergeDoubleArray( std::vector<double>& rArray, ScFullMatrix:: ...@@ -2104,7 +2194,7 @@ void ScMatrixImpl::MergeDoubleArray( std::vector<double>& rArray, ScFullMatrix::
case ScFullMatrix::Mul: case ScFullMatrix::Mul:
{ {
MergeDoubleArrayFunc<ArrayMul> aFunc(rArray); MergeDoubleArrayFunc<ArrayMul> aFunc(rArray);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
} }
break; break;
default: default:
...@@ -2326,16 +2416,26 @@ struct MatrixOpWrapper ...@@ -2326,16 +2416,26 @@ struct MatrixOpWrapper
private: private:
MatrixImplType& mrMat; MatrixImplType& mrMat;
MatrixImplType::position_type pos; MatrixImplType::position_type pos;
T maOp; const T* mpOp;
public: public:
MatrixOpWrapper(MatrixImplType& rMat, T const & aOp): MatrixOpWrapper(MatrixImplType& rMat, const T& aOp):
mrMat(rMat), mrMat(rMat),
pos(rMat.position(0,0)), pos(rMat.position(0,0)),
maOp(aOp) mpOp(&aOp)
{ {
} }
MatrixOpWrapper( const MatrixOpWrapper& r ) : mrMat(r.mrMat), pos(r.pos), mpOp(r.mpOp) {}
MatrixOpWrapper& operator= ( const MatrixOpWrapper& r )
{
mrMat = r.mrMat;
pos = r.pos;
mpOp = r.mpOp;
return *this;
}
void operator()(const MatrixImplType::element_block_node_type& node) void operator()(const MatrixImplType::element_block_node_type& node)
{ {
switch (node.type) switch (node.type)
...@@ -2346,7 +2446,7 @@ public: ...@@ -2346,7 +2446,7 @@ public:
block_type::const_iterator it = block_type::begin(*node.data); block_type::const_iterator it = block_type::begin(*node.data);
block_type::const_iterator itEnd = block_type::end(*node.data); block_type::const_iterator itEnd = block_type::end(*node.data);
MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp); MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, *mpOp);
pos = mrMat.set(pos,aFunc.begin(), aFunc.end()); pos = mrMat.set(pos,aFunc.begin(), aFunc.end());
} }
break; break;
...@@ -2357,7 +2457,7 @@ public: ...@@ -2357,7 +2457,7 @@ public:
block_type::const_iterator it = block_type::begin(*node.data); block_type::const_iterator it = block_type::begin(*node.data);
block_type::const_iterator itEnd = block_type::end(*node.data); block_type::const_iterator itEnd = block_type::end(*node.data);
MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp); MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, *mpOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end()); pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
} }
break; break;
...@@ -2368,17 +2468,17 @@ public: ...@@ -2368,17 +2468,17 @@ public:
block_type::const_iterator it = block_type::begin(*node.data); block_type::const_iterator it = block_type::begin(*node.data);
block_type::const_iterator itEnd = block_type::end(*node.data); block_type::const_iterator itEnd = block_type::end(*node.data);
MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp); MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, *mpOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end()); pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
} }
break; break;
case mdds::mtm::element_empty: case mdds::mtm::element_empty:
{ {
if (maOp.useFunctionForEmpty()) if (mpOp->useFunctionForEmpty())
{ {
std::vector<char> aVec(node.size); std::vector<char> aVec(node.size);
MatrixIteratorWrapper<std::vector<char>, T, typename T::number_value_type> MatrixIteratorWrapper<std::vector<char>, T, typename T::number_value_type>
aFunc(aVec.begin(), aVec.end(), maOp); aFunc(aVec.begin(), aVec.end(), *mpOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end()); pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
} }
} }
...@@ -2394,14 +2494,14 @@ template<typename T> ...@@ -2394,14 +2494,14 @@ template<typename T>
void ScMatrixImpl::ApplyOperation(T aOp, ScMatrixImpl& rMat) void ScMatrixImpl::ApplyOperation(T aOp, ScMatrixImpl& rMat)
{ {
MatrixOpWrapper<T> aFunc(rMat.maMat, aOp); MatrixOpWrapper<T> aFunc(rMat.maMat, aOp);
maMat.walk(aFunc); aFunc = maMat.walk(aFunc);
} }
template<typename T> template<typename T>
std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const std::vector<std::unique_ptr<T>>& aOp) std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const std::vector<std::unique_ptr<T>>& aOp)
{ {
WalkElementBlocksMultipleValues<T> aFunc(aOp); WalkElementBlocksMultipleValues<T> aFunc(aOp);
maMat.walk(aFunc); aFunc = maMat.walk(std::move(aFunc));
return aFunc.getResult(); return aFunc.getResult();
} }
...@@ -2541,7 +2641,9 @@ void ScMatrixImpl::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, ...@@ -2541,7 +2641,9 @@ void ScMatrixImpl::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos,
{ {
WalkElementBlockOperation aFunc(maMat.size().row, WalkElementBlockOperation aFunc(maMat.size().row,
aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc); aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc);
maMat.walk(aFunc, MatrixImplType::size_pair_type(rStartPos.first, rStartPos.second), aFunc = maMat.walk(
aFunc,
MatrixImplType::size_pair_type(rStartPos.first, rStartPos.second),
MatrixImplType::size_pair_type(rEndPos.first, rEndPos.second)); MatrixImplType::size_pair_type(rEndPos.first, rEndPos.second));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment