diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-24 17:09:17 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-24 17:09:17 -0700 |
commit | 2fb94e3c4c4ade042fc1944f1bfa64609bff40b4 (patch) | |
tree | a3b649a53a0b634d3110daf2f8357d372a560841 /cpp/041name | |
parent | 544a1f1e17d909673f08a50b97fc9d00df431eb4 (diff) | |
download | mu-2fb94e3c4c4ade042fc1944f1bfa64609bff40b4.tar.gz |
1166
Why did I think STL's map wasn't efficient? It has logarithmic complexity (maintains a tree internally) and is faster than hashing for small containers. It's the more portable solution and should be what I turn to by default.
Diffstat (limited to 'cpp/041name')
-rw-r--r-- | cpp/041name | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cpp/041name b/cpp/041name index 071f6f5a..6afb6b07 100644 --- a/cpp/041name +++ b/cpp/041name @@ -21,7 +21,7 @@ recipe main [ Transform.push_back(transform_names); :(before "End Globals") -unordered_map<recipe_number, unordered_map<string, int> > Name; +map<recipe_number, map<string, int> > Name; :(after "Clear Other State For recently_added_recipes") for (size_t i = 0; i < recently_added_recipes.size(); ++i) { Name.erase(recently_added_recipes[i]); @@ -29,7 +29,7 @@ for (size_t i = 0; i < recently_added_recipes.size(); ++i) { :(code) void transform_names(const recipe_number r) { - unordered_map<string, int>& names = Name[r]; + map<string, int>& names = Name[r]; int curr_idx = 1; //? cout << "Recipe " << r << '\n'; //? 2 //? cout << Recipe[r].steps.size(); //? 1 @@ -77,7 +77,7 @@ void transform_names(const recipe_number r) { } } -bool already_transformed(const reagent& r, const unordered_map<string, int>& names) { +bool already_transformed(const reagent& r, const map<string, int>& names) { return names.find(r.name) != names.end(); } |