Using std::pair

This commit is contained in:
Ingmar Schoegl 2023-08-03 17:16:59 -05:00 committed by Ray Speth
parent 3dae4d458b
commit 8f320c217c
19 changed files with 35 additions and 35 deletions

View File

@ -285,7 +285,7 @@ public:
bool hasMapWhere(const std::string& key, const std::string& value) const;
//! Return values used to determine the sort order when outputting to YAML
std::pair <int, int> order() const;
pair <int, int> order() const;
//! See AnyMap::applyUnits()
void applyUnits(shared_ptr<UnitSystem>& units);
@ -542,10 +542,10 @@ public:
Iterator(const std::unordered_map<std::string, AnyValue>::const_iterator& start,
const std::unordered_map<std::string, AnyValue>::const_iterator& stop);
const std::pair<const std::string, AnyValue>& operator*() const {
const pair<const std::string, AnyValue>& operator*() const {
return *m_iter;
}
const std::pair<const std::string, AnyValue>* operator->() const {
const pair<const std::string, AnyValue>* operator->() const {
return &*m_iter;
}
bool operator!=(const Iterator& right) const {
@ -579,13 +579,13 @@ public:
OrderedIterator begin() const;
OrderedIterator end() const;
typedef vector<std::pair<
std::pair<int, int>,
const std::pair<const std::string, AnyValue>*>> OrderVector;
typedef vector<pair<
pair<int, int>,
const pair<const std::string, AnyValue>*>> OrderVector;
private:
const AnyMap* m_data;
OrderVector m_ordered;
unique_ptr<std::pair<const std::string, AnyValue>> m_units;
unique_ptr<pair<const std::string, AnyValue>> m_units;
};
//! Defined to allow the OrderedProxy class to be used with range-based
@ -596,10 +596,10 @@ public:
OrderedIterator(const AnyMap::OrderedProxy::OrderVector::const_iterator& start,
const AnyMap::OrderedProxy::OrderVector::const_iterator& stop);
const std::pair<const std::string, AnyValue>& operator*() const {
const pair<const std::string, AnyValue>& operator*() const {
return *m_iter->second;
}
const std::pair<const std::string, AnyValue>* operator->() const {
const pair<const std::string, AnyValue>* operator->() const {
return &(*m_iter->second);
}
bool operator!=(const OrderedIterator& right) const {

View File

@ -109,7 +109,7 @@ struct UnitStack
}
//! Alternative constructor allows for direct assignment of vector
UnitStack(std::initializer_list<std::pair<Units, double>> units)
UnitStack(std::initializer_list<pair<Units, double>> units)
: stack(units) {}
UnitStack() = default;
@ -137,7 +137,7 @@ struct UnitStack
//! Calculate product of units-exponent stack
Units product() const;
vector<std::pair<Units, double>> stack; //!< Stack uses vector of pairs
vector<pair<Units, double>> stack; //!< Stack uses vector of pairs
};

View File

@ -177,7 +177,7 @@ public:
protected:
//! Pairs of species indices and multipliers to calculate enthalpy change
vector<std::pair<size_t, double>> m_stoich_coeffs;
vector<pair<size_t, double>> m_stoich_coeffs;
double m_deltaH_R = 0.0; //!< enthalpy change of reaction (in temperature units)
};

View File

@ -1459,7 +1459,7 @@ public:
* both elements of the pair. If no unmarked duplicates or unmatched marked
* duplicate reactions are found, returns `(npos, npos)`.
*/
virtual std::pair<size_t, size_t> checkDuplicates(bool throw_err=true) const;
virtual pair<size_t, size_t> checkDuplicates(bool throw_err=true) const;
/**
* Takes as input an array of properties for all species in the mechanism

View File

@ -209,7 +209,7 @@ protected:
}
//! Vector of pairs of reaction rates indices and reaction rates
vector<std::pair<size_t, RateType>> m_rxn_rates;
vector<pair<size_t, RateType>> m_rxn_rates;
std::map<size_t, size_t> m_indices; //! Mapping of indices
DataType m_shared;
};

View File

@ -182,7 +182,7 @@ public:
protected:
//! log(p) to (index range) in the rates_ vector
std::map<double, std::pair<size_t, size_t>> pressures_;
std::map<double, pair<size_t, size_t>> pressures_;
// Rate expressions which are referenced by the indices stored in pressures_
vector<ArrheniusRate> rates_;

View File

@ -156,7 +156,7 @@ public:
R[m_rxn] -= S[m_ic0];
}
void resizeCoeffs(const std::map<std::pair<size_t, size_t>, size_t>& indices)
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices)
{
m_jc0 = indices.at({m_rxn, m_ic0});
}
@ -218,7 +218,7 @@ public:
R[m_rxn] -= (S[m_ic0] + S[m_ic1]);
}
void resizeCoeffs(const std::map<std::pair<size_t, size_t>, size_t>& indices)
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices)
{
m_jc0 = indices.at({m_rxn, m_ic0});
m_jc1 = indices.at({m_rxn, m_ic1});
@ -289,7 +289,7 @@ public:
R[m_rxn] -= (S[m_ic0] + S[m_ic1] + S[m_ic2]);
}
void resizeCoeffs(const std::map<std::pair<size_t, size_t>, size_t>& indices)
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices)
{
m_jc0 = indices.at({m_rxn, m_ic0});
m_jc1 = indices.at({m_rxn, m_ic1});
@ -392,7 +392,7 @@ public:
}
}
void resizeCoeffs(const std::map<std::pair<size_t, size_t>, size_t>& indices)
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices)
{
for (size_t i = 0; i < m_n; i++) {
m_jc[i] = indices.at({m_rxn, m_ic[i]});
@ -622,7 +622,7 @@ public:
m_values.resize(nCoeffs, 0.);
// Set up index pairs for derivatives
std::map<std::pair<size_t, size_t>, size_t> indices;
std::map<pair<size_t, size_t>, size_t> indices;
size_t n = 0;
for (int i = 0; i < tmp.outerSize(); i++) {
for (Eigen::SparseMatrix<double>::InnerIterator it(tmp, i); it; ++it) {

View File

@ -203,7 +203,7 @@ protected:
//! Mark species *k* as having its thermodynamic data installed
void markInstalled(size_t k);
typedef std::pair<size_t, shared_ptr<SpeciesThermoInterpType> > index_STIT;
typedef pair<size_t, shared_ptr<SpeciesThermoInterpType> > index_STIT;
typedef std::map<int, vector<index_STIT> > STIT_map;
typedef std::map<int, vector<double>> tpoly_map;
@ -219,7 +219,7 @@ protected:
//! Map from species index to location within #m_sp, such that
//! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
//! SpeciesThermoInterpType object for species `k`.
std::map<size_t, std::pair<int, size_t> > m_speciesLoc;
std::map<size_t, pair<int, size_t> > m_speciesLoc;
//! Maximum value of the lowest temperature
double m_tlow_max = 0.0;

View File

@ -238,7 +238,7 @@ protected:
Array2D a_coeff_vec;
//! Explicitly-specified binary interaction parameters
std::map<std::string, std::map<std::string, std::pair<double, double>>> m_binaryParameters;
std::map<std::string, std::map<std::string, pair<double, double>>> m_binaryParameters;
enum class CoeffSource { EoS, CritProps, Database };
//! For each species, specifies the source of the a and b coefficients

View File

@ -1106,7 +1106,7 @@ bool AnyValue::hasMapWhere(const std::string& key, const std::string& value) con
}
}
std::pair<int, int> AnyValue::order() const
pair<int, int> AnyValue::order() const
{
return {m_line, m_column};
}
@ -1594,7 +1594,7 @@ AnyMap::OrderedProxy::OrderedProxy(const AnyMap& data)
m_units = make_unique<pair<const string, AnyValue>>(
"units", m_data->at("__units__"));
m_units->second.setFlowStyle();
m_ordered.emplace_back(std::pair<int, int>{-2, 0}, m_units.get());
m_ordered.emplace_back(pair<int, int>{-2, 0}, m_units.get());
}
int head = 0; // sort key of the first programmatically-added item

View File

@ -170,7 +170,7 @@ void Storage::deleteGroup(const string& id)
}
}
std::pair<size_t, set<string>> Storage::contents(const string& id) const
pair<size_t, set<string>> Storage::contents(const string& id) const
{
try {
checkGroupRead(id);
@ -606,7 +606,7 @@ void Storage::deleteGroup(const string& id)
"Saving to HDF requires HighFive installation.");
}
std::pair<size_t, set<string>> Storage::contents(const string& id) const
pair<size_t, set<string>> Storage::contents(const string& id) const
{
throw CanteraError("Storage::contents",
"Saving to HDF requires HighFive installation.");

View File

@ -584,7 +584,7 @@ double UnitSystem::convertFrom(double value, const Units& src) const
* pow(m_energy_factor, -src.m_energy_dim);
}
static std::pair<double, std::string> split_unit(const AnyValue& v) {
static pair<double, std::string> split_unit(const AnyValue& v) {
if (v.is<std::string>()) {
// Should be a value and units, separated by a space, for example '2e4 J/kmol'
std::string val_units = v.asString();

View File

@ -593,7 +593,7 @@ double MultiPhaseEquil::computeReactionSteps(vector<double>& dxi)
void MultiPhaseEquil::computeN()
{
// Sort the list of species by mole fraction (decreasing order)
vector<std::pair<double, size_t> > moleFractions(m_nsp);
vector<pair<double, size_t> > moleFractions(m_nsp);
for (size_t k = 0; k < m_nsp; k++) {
// use -Xk to generate reversed sort order
moleFractions[k] = {-m_mix->speciesMoles(m_species[k]), k};

View File

@ -1843,7 +1843,7 @@ int VCS_SOLVE::vcs_report(int iconv)
bool inertYes = false;
// SORT DEPENDENT SPECIES IN DECREASING ORDER OF MOLES
vector<std::pair<double, size_t>> x_order;
vector<pair<double, size_t>> x_order;
for (size_t i = 0; i < m_nsp; i++) {
x_order.push_back({-m_molNumSpecies_old[i], i});
}

View File

@ -104,7 +104,7 @@ void Kinetics::checkSpeciesArraySize(size_t kk) const
}
}
std::pair<size_t, size_t> Kinetics::checkDuplicates(bool throw_err) const
pair<size_t, size_t> Kinetics::checkDuplicates(bool throw_err) const
{
//! Map of (key indicating participating species) to reaction numbers
std::map<size_t, vector<size_t> > participants;

View File

@ -110,7 +110,7 @@ void BinarySolutionTabulatedThermo::initThermo()
}
// Sort the x, h, s, vmol data in the order of increasing x
vector<std::pair<double,double>> x_h(N), x_s(N), x_vmol(N);
vector<pair<double,double>> x_h(N), x_s(N), x_vmol(N);
for(size_t i = 0; i < N; i++) {
x_h[i] = {x[i], h[i]};
x_s[i] = {x[i], s[i]};

View File

@ -196,7 +196,7 @@ void MoleReactor::updateState(double* y)
};
double T = m_thermo->temperature();
boost::uintmax_t maxiter = 100;
std::pair<double, double> TT;
pair<double, double> TT;
try {
TT = bmt::bracket_and_solve_root(
u_err, T, 1.2, true, bmt::eps_tolerance<double>(48), maxiter);

View File

@ -143,7 +143,7 @@ void Reactor::updateState(double* y)
double T = m_thermo->temperature();
boost::uintmax_t maxiter = 100;
std::pair<double, double> TT;
pair<double, double> TT;
try {
TT = bmt::bracket_and_solve_root(
u_err, T, 1.2, true, bmt::eps_tolerance<double>(48), maxiter);

View File

@ -405,7 +405,7 @@ TEST(Reaction, PlogFromYaml)
auto R = newReaction(rxn, *(sol->kinetics()));
EXPECT_FALSE(R->usesThirdBody());
const auto& rateMap = std::dynamic_pointer_cast<PlogRate>(R->rate())->getRates();
vector<std::pair<double, ArrheniusRate>> rates(rateMap.begin(), rateMap.end());
vector<pair<double, ArrheniusRate>> rates(rateMap.begin(), rateMap.end());
EXPECT_EQ(rates.size(), (size_t) 4);
EXPECT_NEAR(rates[0].first, 0.039474 * OneAtm, 1e-6);
EXPECT_NEAR(rates[2].first, OneAtm, 1e-6);