00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef HELPERFUNCTORS_H
00012 #define HELPERFUNCTORS_H
00013 #include <cassert>
00014 #include <cstdlib>
00015 #include <iterator>
00016 #include <set>
00017 #include <algorithm>
00018
00019
00020 namespace utilities {
00021
00022 template <typename T>
00023 struct del_fun_t {
00024 void operator()(T* p) {
00025 assert(p != NULL);
00026 delete p;
00027 }
00028 };
00029
00030
00031
00032 template <typename InputIterator1, typename InputIterator2, typename OutputIterator>
00033 void vec_difference(InputIterator1 first1, InputIterator1 last1,
00034 InputIterator2 first2, InputIterator2 last2,
00035 OutputIterator result)
00036 {
00037 std::sort(first1, last1);
00038 std::sort(first2, last2);
00039
00040
00041 assert(std::set<typename std::iterator_traits<InputIterator1>::value_type>(first1,last1).size()
00042 ==(unsigned)(last1-first1));
00043 assert(std::set<typename std::iterator_traits<InputIterator2>::value_type>(first2,last2).size()
00044 ==(unsigned)(last2-first2));
00045
00046 std::set_difference(first1, last1, first2, last2, result);
00047
00048 }
00049 }
00050
00051 #endif