Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: utils.h

Issue 3530011: AU: ApplyMap utility function (Closed) Base URL: ssh://git@chromiumos-git/update_engine.git
Patch Set: fixes for review Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils.h
diff --git a/utils.h b/utils.h
index a46ffef40d4e4600e53108a0610a9a799cbc967d..bfe73784d9d940e971ed4330d84eba3ff1ece04c 100644
--- a/utils.h
+++ b/utils.h
@@ -182,6 +182,19 @@ bool VectorIndexOf(const std::vector<T>& vect, const T& value,
}
}
+template<typename ValueType>
+void ApplyMap(std::vector<ValueType>* collection,
+ const std::map<ValueType, ValueType>& the_map) {
+ for (typename std::vector<ValueType>::iterator it = collection->begin();
+ it != collection->end(); ++it) {
+ typename std::map<ValueType, ValueType>::const_iterator map_it =
+ the_map.find(*it);
+ if (map_it != the_map.end()) {
+ *it = map_it->second;
+ }
+ }
+}
+
// Returns the currently booted device. "/dev/sda3", for example.
// This will not interpret LABEL= or UUID=. You'll need to use findfs
// or something with equivalent funcionality to interpret those.
« no previous file with comments | « no previous file | utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698