brintos

brintos / llvm-project-archived public Read only

0
0
Text · 815 B · 8c57f5c Raw
35 lines · plain
1 2#ifndef _SIM_MAP3#define _SIM_MAP4 5#pragma clang system_header6#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 std33 34#endif // _SIM_MAP35