Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef MAP_FILT_H
- #define MAP_FILT_H
- #include <vector>
- #include <map>
- template<typename T, typename T2, class Func>
- class map_filter_view
- {
- private:
- std::map<T, T2>& myMap;
- Func func;
- public:
- map_filter_view(std::map<T, T2>& myMap)
- {
- this->myMap = myMap;
- }
- int count (T key) const
- {
- int sum = 0;
- for (std::pair<T, T2>& item : myMap)
- {
- if (!func(item) && item.first == key)
- {
- ++sum;
- }
- }
- return sum;
- }
- int size () const
- {
- int sum = 0;
- for (std::pair<T, T2>& item : myMap)
- {
- if (!func(item))
- {
- ++sum;
- }
- }
- return sum;
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement