aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/stl_util.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-06-13 17:06:08 +0000
committerlloyd <[email protected]>2011-06-13 17:06:08 +0000
commit5fcdf6953ed820a446862702311221c10ae0b91d (patch)
tree10354a54bb8ef5c8f9c6cdd9fa0142ab0037c635 /src/utils/stl_util.h
parentb145e593616e83a4c124bba70d451ef0f03c5f3f (diff)
parent1a28f7ef6064041955e7a662c5e087bbea03b6ad (diff)
propagate from branch 'net.randombit.botan' (head 150bd11dd8090559ee1e83394b8283bf93a018de)
to branch 'net.randombit.botan.c++0x' (head 7480693bb3f1e8a4e039a3e7ba3d9a7007f9730e)
Diffstat (limited to 'src/utils/stl_util.h')
-rw-r--r--src/utils/stl_util.h47
1 files changed, 9 insertions, 38 deletions
diff --git a/src/utils/stl_util.h b/src/utils/stl_util.h
index 0e0617d5b..0eb078244 100644
--- a/src/utils/stl_util.h
+++ b/src/utils/stl_util.h
@@ -12,27 +12,7 @@
namespace Botan {
-/**
-* Copy-on-Predicate Algorithm
-* @param current the first iterator value
-* @param end the final iterator value
-* @param dest an output iterator
-* @param copy_p the predicate
-*/
-template<typename InputIterator, typename OutputIterator, typename Predicate>
-OutputIterator copy_if(InputIterator current, InputIterator end,
- OutputIterator dest, Predicate copy_p)
- {
- while(current != end)
- {
- if(copy_p(*current))
- *dest++ = *current;
- ++current;
- }
- return dest;
- }
-
-/**
+/*
* Searching through a std::map
* @param mapping the map to search
* @param key is what to look for
@@ -50,26 +30,17 @@ inline V search_map(const std::map<K, V>& mapping,
return i->second;
}
-/**
-* Function adaptor for delete operation
-*/
-template<class T>
-class del_fun : public std::unary_function<T, void>
+template<typename K, typename V, typename R>
+inline R search_map(const std::map<K, V>& mapping, const K& key,
+ const R& null_result, const R& found_result)
{
- public:
- void operator()(T* ptr) { delete ptr; }
- };
-
-/**
-* Delete the second half of a pair of objects
-*/
-template<typename Pair>
-void delete2nd(Pair& pair)
- {
- delete pair.second;
+ typename std::map<K, V>::const_iterator i = mapping.find(key);
+ if(i == mapping.end())
+ return null_result;
+ return found_result;
}
-/**
+/*
* Insert a key/value pair into a multimap
*/
template<typename K, typename V>