diff options
-rw-r--r-- | project2/lib/safeMapFind.h | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/project2/lib/safeMapFind.h b/project2/lib/safeMapFind.h deleted file mode 100644 index a5786bc..0000000 --- a/project2/lib/safeMapFind.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef SAFEMAPFIND_H -#define SAFEMAPFIND_H - -template <class Ex, class Map> -typename Map::const_iterator -safeMapFind(const Map & map, const typename Map::key_type & key) -{ - typename Map::const_iterator i = map.find(key); - if (i == map.end()) { - throw Ex(key); - } - return i; -} - -template <class Map> -typename Map::mapped_type -defaultMapFind(const Map & map, const typename Map::key_type & key, const typename Map::mapped_type & def = typename Map::mapped_type()) -{ - typename Map::const_iterator i = map.find(key); - if (i == map.end()) { - return def; - } - return i->second; -} - -template <class Ex, class Map> -const typename Map::mapped_type & -safeMapLookup(const Map & map, const typename Map::key_type & key) -{ - typename Map::const_iterator i = map.find(key); - if (i == map.end()) { - throw Ex(key); - } - return i->second; -} - -template <class Cont> -bool -containerContains(const Cont & c, const typename Cont::value_type & v) -{ - return (std::find(c.begin(), c.end(), v) != c.end()); -} - -#endif - |