add some util functions to gd map :map:

This commit is contained in:
dankmeme01 2024-03-15 21:12:56 +01:00
parent d165616700
commit e4ab8819f5

View file

@ -194,6 +194,24 @@ namespace gd {
return (*__i).second;
}
V& at(K const& __k) {
iterator __i = lower_bound(__k);
if (__i == end() || compare(__k, (*__i).first)) {
throw std::out_of_range("map::at");
}
return (*__i).second;
}
const V& at(K const& __k) const {
iterator __i = lower_bound(__k);
if (__i == end() || compare(__k, (*__i).first)) {
throw std::out_of_range("map::at");
}
return (*__i).second;
}
iterator begin() noexcept {
return iterator(m_header.m_left);
}
@ -249,6 +267,10 @@ namespace gd {
return find(__x) != end() ? 1 : 0;
}
bool contains(K const& __x) {
return count() > 0;
}
map(map const& lol) : map(std::map<K, V>(lol)) {}
map() : map(std::map<K, V>()) {}