More C++11ification.

1. Replace HashMap and HashSet with std::unordered_map and
   std::unordered_set respectively.
2. Extract the pair hasher into a struct pair_hash.
3. Delete collections_port.h
4. Convert explicit iterator based loops to auto based
   loops where sensible.

Change-Id: Ib88bcd13a7463d18435639d3b771abaa52080efb
This commit is contained in:
Sameer Agarwal
2018-03-29 22:01:29 -07:00
parent ffae101c75
commit a1458f3348
35 changed files with 248 additions and 442 deletions
+7 -12
View File
@@ -234,23 +234,18 @@ bool ApplyOrdering(const ProblemImpl::ParameterMap& parameter_map,
parameter_blocks->clear();
const map<int, set<double*> >& groups = ordering.group_to_elements();
for (map<int, set<double*> >::const_iterator group_it = groups.begin();
group_it != groups.end();
++group_it) {
const set<double*>& group = group_it->second;
for (set<double*>::const_iterator parameter_block_ptr_it = group.begin();
parameter_block_ptr_it != group.end();
++parameter_block_ptr_it) {
ProblemImpl::ParameterMap::const_iterator parameter_block_it =
parameter_map.find(*parameter_block_ptr_it);
if (parameter_block_it == parameter_map.end()) {
for (const auto& p : groups) {
const set<double*>& group = p.second;
for (double* parameter_block_ptr : group) {
auto it = parameter_map.find(parameter_block_ptr);
if (it == parameter_map.end()) {
*error = StringPrintf("User specified ordering contains a pointer "
"to a double that is not a parameter block in "
"the problem. The invalid double is in group: %d",
group_it->first);
p.first);
return false;
}
parameter_blocks->push_back(parameter_block_it->second);
parameter_blocks->push_back(it->second);
}
}
return true;