cpp-btree: Add contains method to match STL

This commit is contained in:
Jonathan G Rennison 2024-08-21 22:10:06 +01:00
parent e060e9b83d
commit 44dffb0e81

View File

@ -192,6 +192,9 @@ class btree_unique_container : public btree_container<Tree> {
size_type count(const key_type &key) const {
return this->tree_.count_unique(key);
}
bool contains(const key_type &key) const {
return this->count(key) > 0;
}
// Insertion routines.
std::pair<iterator,bool> insert(const value_type &x) {
@ -311,6 +314,9 @@ class btree_multi_container : public btree_container<Tree> {
size_type count(const key_type &key) const {
return this->tree_.count_multi(key);
}
bool contains(const key_type &key) const {
return this->find(key) != this->end();
}
// Insertion routines.
iterator insert(const value_type &x) {