copied everything over from 2012 and removed all of the actual robot code except the drivetrain stuff
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4078 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/map_utils.h b/aos/map_utils.h
new file mode 100644
index 0000000..5b85091
--- /dev/null
+++ b/aos/map_utils.h
@@ -0,0 +1,30 @@
+#ifndef AOS_MAP_UTILS_H_
+#define AOS_MAP_UTILS_H_
+
+// TODO(aschuh): Template std::map as well.
+// Maps the key to the value, inserting it if it isn't there, or replacing it if
+// it is. Returns true if the key was added and false if it was replaced.
+template <typename K, typename V>
+bool InsertIntoMap(std::map<K, V> *my_map, const K &key, const V &new_value) {
+ std::pair<typename std::map<K, V>::iterator, bool> element;
+ element = my_map->insert(std::pair<K,V>(key, new_value));
+ if (element.second == false) {
+ element.first->second = new_value;
+ }
+ return element.second;
+}
+
+// Gets the value for the key from the map.
+// Returns true if the key was found and then populates *value with the value.
+// Otherwise, leaves value alone and returns false.
+template <typename K, typename V>
+bool GetFromMap(const std::map<K, V> &my_map, const K &key, V *value) {
+ typename std::map<K, V>::const_iterator element = my_map.find(key);
+ if (element != my_map.end()) {
+ *value = element->second;
+ return true;
+ }
+ return false;
+}
+
+#endif // AOS_MAP_UTILS_H_