Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/ygm/container/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <boost/unordered/unordered_flat_map.hpp>
#include <ygm/container/container_traits.hpp>
#include <ygm/container/detail/base_async_contains.hpp>
#include <ygm/container/detail/base_async_erase.hpp>
#include <ygm/container/detail/base_async_insert.hpp>
#include <ygm/container/detail/base_async_insert_or_assign.hpp>
Expand All @@ -32,6 +33,8 @@ class map
public detail::base_contains<map<Key, Value>, std::tuple<Key, Value>>,
public detail::base_count<map<Key, Value>, std::tuple<Key, Value>>,
public detail::base_async_reduce<map<Key, Value>, std::tuple<Key, Value>>,
public detail::base_async_contains<map<Key, Value>,
std::tuple<Key, Value>>,
public detail::base_async_erase_key<map<Key, Value>,
std::tuple<Key, Value>>,
public detail::base_async_erase_key_value<map<Key, Value>,
Expand Down
33 changes: 33 additions & 0 deletions test/test_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,39 @@ int main(int argc, char **argv) {
YGM_ASSERT_RELEASE(!smap.contains("blue"));
}

//
// Test async_contains
{
ygm::container::map<std::string, std::string> smap(world);

smap.async_insert("dog", "cat");
smap.async_insert("apple", "orange");

world.barrier();

auto contains_key_functor = [](const bool is_present,
const std::string &key,
const std::string &sent_key) {
YGM_ASSERT_RELEASE(key == sent_key);
YGM_ASSERT_RELEASE(is_present == true);
};

auto does_not_contain_key_functor = [](const bool is_present,
const std::string &key,
const std::string &sent_key) {
YGM_ASSERT_RELEASE(key == sent_key);
YGM_ASSERT_RELEASE(is_present == false);
};

smap.async_contains("dog", contains_key_functor, std::string("dog"));
smap.async_contains("apple", contains_key_functor, std::string("apple"));

smap.async_contains("fish", does_not_contain_key_functor,
std::string("fish"));
smap.async_contains("tomato", does_not_contain_key_functor,
std::string("tomato"));
}

// Test batch erase from set
{
int num_items = 100;
Expand Down
Loading