Il2CppHashMap.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "../external/google/sparsehash/dense_hash_map.h"
  3. #include "KeyWrapper.h"
  4. template<class Key, class T,
  5. class HashFcn,
  6. class EqualKey = std::equal_to<Key>,
  7. class Alloc = std::allocator<std::pair<const KeyWrapper<Key>, T> > >
  8. class Il2CppHashMap : public dense_hash_map<KeyWrapper<Key>, T, HashFcn, typename KeyWrapper<Key>::template EqualsComparer<EqualKey>, Alloc>
  9. {
  10. private:
  11. typedef dense_hash_map<KeyWrapper<Key>, T, HashFcn, typename KeyWrapper<Key>::template EqualsComparer<EqualKey>, Alloc> Base;
  12. public:
  13. typedef typename Base::size_type size_type;
  14. typedef typename Base::hasher hasher;
  15. typedef typename Base::key_equal key_equal;
  16. typedef typename Base::key_type key_type;
  17. explicit Il2CppHashMap(size_type n = 0,
  18. const hasher& hf = hasher(),
  19. const EqualKey& eql = EqualKey()) :
  20. Base(n, hf, key_equal(eql))
  21. {
  22. Base::set_empty_key(key_type(key_type::KeyType_Empty));
  23. Base::set_deleted_key(key_type(key_type::KeyType_Deleted));
  24. }
  25. template<class InputIterator>
  26. Il2CppHashMap(InputIterator f, InputIterator l,
  27. size_type n = 0,
  28. const hasher& hf = hasher(),
  29. const EqualKey& eql = EqualKey()) :
  30. Base(f, l, n, hf, key_equal(eql))
  31. {
  32. Base::set_empty_key(key_type(key_type::KeyType_Empty));
  33. Base::set_deleted_key(key_type(key_type::KeyType_Deleted));
  34. }
  35. void add(const key_type& key, const T& value)
  36. {
  37. Base::insert(std::make_pair(key, value));
  38. }
  39. };