2 #include <unordered_map> 100 template <
typename Key,
typename T,
101 typename Hash = std::hash<Key>,
typename Pred = std::equal_to<Key>,
102 typename Alloc = std::allocator<std::pair<const Key, T>>>
104 :
public std::unordered_map<Key, T, Hash, Pred, Alloc>
107 typedef std::unordered_map<Key, T, Hash, Pred, Alloc> super;
110 auto at(
const Key &) -> T& =
delete;
111 auto at(
const Key &)
const ->
const T& =
delete;
125 auto has(
const Key &key)
const ->
bool 127 return count(key) != 0;
144 auto get(
const Key &key) -> T&
146 return find(key)->second;
148 auto get(
const Key &key)
const ->
const T&
150 return find(key)->second;
165 void set(
const Key &key,
const T &val)
167 iterator it = find(key);
171 insert({ key, val });
173 void set(
const Key &key,
const T &&val)
175 iterator it = find(key);
179 insert({ key, val });
188 auto pop(
const Key &key) -> T
190 iterator it = find(key);
auto has(const Key &key) const -> bool
Whether have the item or not.
auto pop(const Key &key) -> T
Pop item.
Customized std::unordered_map.