remove hash_map/hash_set; replace with std::unordered_map|set
This commit is contained in:
@@ -468,7 +468,7 @@ bool MPSolver::SupportsProblemType(OptimizationProblemType problem_type) {
|
||||
}
|
||||
|
||||
MPVariable* MPSolver::LookupVariableOrNull(const std::string& var_name) const {
|
||||
hash_map<std::string, int>::const_iterator it =
|
||||
std::unordered_map<std::string, int>::const_iterator it =
|
||||
variable_name_to_index_.find(var_name);
|
||||
if (it == variable_name_to_index_.end()) return nullptr;
|
||||
return variables_[it->second];
|
||||
@@ -476,7 +476,7 @@ MPVariable* MPSolver::LookupVariableOrNull(const std::string& var_name) const {
|
||||
|
||||
MPConstraint* MPSolver::LookupConstraintOrNull(const std::string& constraint_name)
|
||||
const {
|
||||
hash_map<std::string, int>::const_iterator it =
|
||||
std::unordered_map<std::string, int>::const_iterator it =
|
||||
constraint_name_to_index_.find(constraint_name);
|
||||
if (it == constraint_name_to_index_.end()) return nullptr;
|
||||
return constraints_[it->second];
|
||||
@@ -663,7 +663,7 @@ void MPSolver::ExportModelToProto(MPModelProto* output_model) const {
|
||||
// This step is needed as long as the variable indices are given by the
|
||||
// underlying solver at the time of model extraction.
|
||||
// TODO(user): remove this step.
|
||||
hash_map<const MPVariable*, int> var_to_index;
|
||||
std::unordered_map<const MPVariable*, int> var_to_index;
|
||||
for (int j = 0; j < variables_.size(); ++j) {
|
||||
var_to_index[variables_[j]] = j;
|
||||
}
|
||||
@@ -1606,4 +1606,3 @@ int MPSolverParameters::GetIntegerParam(MPSolverParameters::IntegerParam param)
|
||||
|
||||
|
||||
} // namespace operations_research
|
||||
|
||||
|
||||
@@ -590,14 +590,14 @@ class MPSolver {
|
||||
// The vector of variables in the problem.
|
||||
std::vector<MPVariable*> variables_;
|
||||
// A map from a variable's name to its index in variables_.
|
||||
hash_map<std::string, int> variable_name_to_index_;
|
||||
std::unordered_map<std::string, int> variable_name_to_index_;
|
||||
// Whether constraints have been extracted to the underlying interface.
|
||||
std::vector<bool> variable_is_extracted_;
|
||||
|
||||
// The vector of constraints in the problem.
|
||||
std::vector<MPConstraint*> constraints_;
|
||||
// A map from a constraint's name to its index in constraints_.
|
||||
hash_map<std::string, int> constraint_name_to_index_;
|
||||
std::unordered_map<std::string, int> constraint_name_to_index_;
|
||||
// Whether constraints have been extracted to the underlying interface.
|
||||
std::vector<bool> constraint_is_extracted_;
|
||||
|
||||
@@ -636,11 +636,11 @@ inline std::ostream& operator<<(std::ostream& os,
|
||||
// The data structure used to store the coefficients of the contraints and of
|
||||
// the objective. Also define a type to facilitate iteration over them with:
|
||||
// for (CoeffEntry entry : coefficients_) { ... }
|
||||
class CoeffMap : public hash_map<const MPVariable*, double> {
|
||||
class CoeffMap : public std::unordered_map<const MPVariable*, double> {
|
||||
public:
|
||||
explicit CoeffMap(int num_buckets)
|
||||
#if !defined(_MSC_VER) // Visual C++ doesn't support this constructor
|
||||
: hash_map<const MPVariable*, double>(num_buckets)
|
||||
: std::unordered_map<const MPVariable*, double>(num_buckets)
|
||||
#endif // _MSC_VER
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class NameManager {
|
||||
std::string MakeUniqueName(const std::string& name);
|
||||
|
||||
private:
|
||||
hash_set<std::string> names_set_;
|
||||
std::unordered_set<std::string> names_set_;
|
||||
int last_n_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user