#ifndef V8_HEAP_BASE_CACHED_UNORDERED_MAP_H_
#define V8_HEAP_BASE_CACHED_UNORDERED_MAP_H_
#include <unordered_map>
#include "src/base/functional.h"
namespace heap::base {
template <typename _Key, typename _Value, typename _Hash = v8::base::hash<_Key>>
class CachedUnorderedMap final {
using MapT = std::unordered_map<_Key, _Value, _Hash>;
public:
using Key = typename MapT::key_type;
using Mapped = typename MapT::mapped_type;
Mapped& operator[](const Key& key) { … }
typename MapT::size_type erase(const Key& key) { … }
typename MapT::iterator find(const Key& key) { … }
typename MapT::iterator begin() { … }
typename MapT::iterator end() { … }
typename MapT::const_iterator begin() const { … }
typename MapT::const_iterator end() const { … }
void clear() { … }
bool empty() const { … }
MapT Take() { … }
private:
Key last_key_ = nullptr;
Mapped* last_mapped_ = nullptr;
MapT map_;
};
}
#endif