diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-27 23:20:29 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-30 11:16:00 +0200 |
commit | 5ba84c3c7080d55d86b8b39db077b6da36cb700a (patch) | |
tree | a71491f3d336a314ab63e834bd013f0503be967b /sccomp/source/solver/CoinMPSolver.cxx | |
parent | 850693273970be2662cce8f4d2710b3657a02f65 (diff) |
Simplify Sequence iterations in scaddins, sccomp, scripting
Use range-based loops, STL and comphelper functions
Change-Id: I836422a1c81a3dc9585687ed2e506eb59bb4ec91
Reviewed-on: https://gerrit.libreoffice.org/76484
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sccomp/source/solver/CoinMPSolver.cxx')
-rw-r--r-- | sccomp/source/solver/CoinMPSolver.cxx | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/sccomp/source/solver/CoinMPSolver.cxx b/sccomp/source/solver/CoinMPSolver.cxx index cd2973580997..b422c3456875 100644 --- a/sccomp/source/solver/CoinMPSolver.cxx +++ b/sccomp/source/solver/CoinMPSolver.cxx @@ -63,10 +63,7 @@ void SAL_CALL CoinMPSolver::solve() // collect variables in vector (?) - std::vector<table::CellAddress> aVariableCells; - aVariableCells.reserve(maVariables.getLength()); - for (sal_Int32 nPos=0; nPos<maVariables.getLength(); nPos++) - aVariableCells.push_back( maVariables[nPos] ); + auto aVariableCells = comphelper::sequenceToContainer<std::vector<table::CellAddress>>(maVariables); size_t nVariables = aVariableCells.size(); size_t nVar = 0; @@ -75,12 +72,12 @@ void SAL_CALL CoinMPSolver::solve() ScSolverCellHashMap aCellsHash; aCellsHash[maObjective].reserve( nVariables + 1 ); // objective function - for (sal_Int32 nConstrPos = 0; nConstrPos < maConstraints.getLength(); ++nConstrPos) + for (const auto& rConstr : maConstraints) { - table::CellAddress aCellAddr = maConstraints[nConstrPos].Left; + table::CellAddress aCellAddr = rConstr.Left; aCellsHash[aCellAddr].reserve( nVariables + 1 ); // constraints: left hand side - if ( maConstraints[nConstrPos].Right >>= aCellAddr ) + if ( rConstr.Right >>= aCellAddr ) aCellsHash[aCellAddr].reserve( nVariables + 1 ); // constraints: right hand side } @@ -258,13 +255,13 @@ void SAL_CALL CoinMPSolver::solve() // apply single-var integer constraints - for (sal_Int32 nConstrPos = 0; nConstrPos < maConstraints.getLength(); ++nConstrPos) + for (const auto& rConstr : maConstraints) { - sheet::SolverConstraintOperator eOp = maConstraints[nConstrPos].Operator; + sheet::SolverConstraintOperator eOp = rConstr.Operator; if ( eOp == sheet::SolverConstraintOperator_INTEGER || eOp == sheet::SolverConstraintOperator_BINARY ) { - table::CellAddress aLeftAddr = maConstraints[nConstrPos].Left; + table::CellAddress aLeftAddr = rConstr.Left; // find variable index for cell for (nVar=0; nVar<nVariables; nVar++) if ( AddressEqual( aVariableCells[nVar], aLeftAddr ) ) |