Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

What is the proper way to use robin_map in lambda function for parallelizing? #69

Copy link
Copy link

Description

@engcang
Issue body actions

Thank you for the great work

As written in the title, I want to use the robin_map instead of std::unordered_map in lambda function.
Jumping into the code right away, the code below works well with std::unordered_map.

struct DataType
{
  bool to_be_del = false;
  DataType(){};
}

unordered_map<KeyType, DataType> candidates;
tbb::parallel_for_each(candidates.begin(), candidates.end(), [&](auto &cand_)
{
  if (some_condition)
  {
    cand_.second.to_be_del = true;
  }
});

But, as robin_map returns const iterator, the below code cannot be compiled.

tsl::robin_map<KeyType, DataType> candidates;
tbb::parallel_for_each(candidates.begin(), candidates.end(), [&](auto &cand_)
{
  if (some_condition)
  {
    cand_.second.to_be_del = true; // modifying const iterator
    cand_.value().to_be_del = true; // errors: cand_ has no member function named 'value()'
  }
});

As can be seen, I want to use tbb::parallel_for or tbb::parallel_for_each for faster computations.
So I would like to ask if there is a proper way to use robin_map and capture the iterator to modify the value within the lambda function!

Thank you in advance.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.