add contains function #25

This commit is contained in:
2019-05-31 22:40:29 +07:00
parent 16e6a2d082
commit 8237a106ea
8 changed files with 72 additions and 0 deletions

View File

@@ -508,6 +508,18 @@ namespace flat_hpp
: end();
}
bool contains(const key_type& key) const {
return find(key) != end();
}
template < typename K >
std::enable_if_t<
detail::is_transparent_v<Compare, K>,
bool>
contains(const K& key) const {
return find(key) != end();
}
std::pair<iterator, iterator> equal_range(const key_type& key) {
const base_type& comp = *this;
return std::equal_range(begin(), end(), key, comp);

View File

@@ -458,6 +458,18 @@ namespace flat_hpp
: end();
}
bool contains(const key_type& key) const {
return find(key) != end();
}
template < typename K >
std::enable_if_t<
detail::is_transparent_v<Compare, K>,
bool>
contains(const K& key) const {
return find(key) != end();
}
std::pair<iterator, iterator> equal_range(const key_type& key) {
const base_type& comp = *this;
return std::equal_range(begin(), end(), key, comp);

View File

@@ -386,6 +386,18 @@ namespace flat_hpp
: end();
}
bool contains(const key_type& key) const {
return find(key) != end();
}
template < typename K >
std::enable_if_t<
detail::is_transparent_v<Compare, K>,
bool>
contains(const K& key) const {
return find(key) != end();
}
std::pair<iterator, iterator> equal_range(const key_type& key) {
return std::equal_range(begin(), end(), key, key_comp());
}

View File

@@ -436,6 +436,18 @@ namespace flat_hpp
: end();
}
bool contains(const key_type& key) const {
return find(key) != end();
}
template < typename K >
std::enable_if_t<
detail::is_transparent_v<Compare, K>,
bool>
contains(const K& key) const {
return find(key) != end();
}
std::pair<iterator, iterator> equal_range(const key_type& key) {
return std::equal_range(begin(), end(), key, key_comp());
}