| 36 | // exists, or NULL otherwise. |
| 37 | template <class Collection> |
| 38 | const typename Collection::value_type::second_type* FindOrNull( |
| 39 | const Collection& collection, |
| 40 | const typename Collection::value_type::first_type& key) { |
| 41 | typename Collection::const_iterator it = collection.find(key); |
| 42 | if (it == collection.end()) { |
| 43 | return 0; |
| 44 | } |
| 45 | return &it->second; |
| 46 | } |
| 47 | |
| 48 | // Same as above but returns a pointer to the non-const value. |
| 49 | template <class Collection> |