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