1 | #ifndef _SIM_UNORDERED_MAP |
2 | #define _SIM_UNORDERED_MAP |
3 | |
4 | #pragma clang system_header |
5 | #include "sim_initializer_list" |
6 | |
7 | namespace std { |
8 | |
9 | template <typename Key, typename Value> |
10 | class unordered_map { |
11 | public: |
12 | using value_type = pair<Key, Value>; |
13 | unordered_map(); |
14 | unordered_map(initializer_list<pair<Key, Value>> initList); |
15 | value_type& operator[](const Key& key); |
16 | value_type& operator[](Key&& key); |
17 | class iterator { |
18 | public: |
19 | iterator(Key *key): ptr(key) {} |
20 | iterator& operator++() { ++ptr; return *this; } |
21 | bool operator!=(const iterator &other) const { return ptr != other.ptr; } |
22 | const Key &operator*() const { return *ptr; } |
23 | private: |
24 | Key *ptr; |
25 | }; |
26 | Key *val; |
27 | iterator begin() const { return iterator(val); } |
28 | iterator end() const { return iterator(val + 1); } |
29 | }; |
30 | |
31 | } // namespace std |
32 | |
33 | #endif // _SIM_UNORDERED_MAP |
34 | |