Advertisement
CorrM

Unsorted Map

May 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #ifndef UNSORTED_MAP
  2. #define UNSORTED_MAP
  3.  
  4. #pragma once
  5. #include <algorithm>
  6. #include <vector>
  7.  
  8. template <typename K, typename V>
  9. class UnsortedMap : public std::vector<std::pair<K, V>>
  10. {
  11.     using UnsortedMapIt = typename std::vector<std::pair<K, V>>::iterator;
  12. public:
  13.     UnsortedMap() = default;
  14.     UnsortedMap(const UnsortedMapIt& begin, const UnsortedMapIt& end)
  15.     {
  16.         this->assign(begin, end);
  17.     }
  18.  
  19.     UnsortedMapIt find(const K& ref)
  20.     {
  21.         return std::find_if(this->begin(), this->end(), [ref](const std::pair<K, V>& vecItem) {
  22.             return vecItem.first == ref;
  23.         });
  24.     }
  25. };
  26. #endif // !UnsortedMap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement