diff --git a/extras/AssociativeContainers/map.hpp b/extras/AssociativeContainers/map.hpp index 5b556d1..02ccd5d 100644 --- a/extras/AssociativeContainers/map.hpp +++ b/extras/AssociativeContainers/map.hpp @@ -25,4 +25,12 @@ class Map size_t size() { return this->map.size(); } V& operator[] (K const& key) { return this->map[key]; } + + V& at(K const& key) { return this->map.at(key); } + + bool empty() const noexcept { return this->map.empty(); } + + size_t max_size() const { return this->map.max_size(); } + + void clear() noexcept { this->map.clear(); } }; diff --git a/source/stdcpp/map.d b/source/stdcpp/map.d index b7ab616..a04c24f 100644 --- a/source/stdcpp/map.d +++ b/source/stdcpp/map.d @@ -30,4 +30,17 @@ module stdcpp.map; { return this.opIndex(key); // handle rvalue-ref } + + ref Value at( ref const Key key); + + ref Value at(const Key key) + { + return this.at(key); + } + + bool empty() const nothrow; + + size_t max_size() const; + + void clear() nothrow; } \ No newline at end of file diff --git a/source/stdcpp/test/map.d b/source/stdcpp/test/map.d index ecef08f..330b760 100644 --- a/source/stdcpp/test/map.d +++ b/source/stdcpp/test/map.d @@ -17,4 +17,9 @@ unittest mymap.opIndex(2) = 'b'; mymap.opIndex(3) = 'c'; assert(mymap.size == 3); + assert(mymap.empty == 0); + assert(mymap.at(2) == 'b'); + mymap.clear(); + assert(mymap.size == 0); + assert(mymap.empty == 1); }