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

Sign up
Appearance settings

Missing functionality in bulk visit #324

Open
@hlverstoep

Description

I want to write a concurrent cache where I can lookup multiple items at once:

template <class K, class V>
std::vector<std::optional<V>> lookup(const concurrent_flat_map<K, V>& map, const std::vector<K>& keys){
 std::vector<std::optional<V>> result;
 map.cvisit(keys.begin(), keys.end(), [&](const auto& x){
 // PROBLEM: how to get 'i'??
 result[i] = x->second;
 });
 return result;
}

I can't find a way to write this with the current API. I would like a new function that traverses an additional iterator in the same order:

template <class K, class V>
std::vector<std::optional<V>> lookup(const concurrent_flat_map<K, V>& map, const std::vector<K>& keys){
 std::vector<std::optional<V>> result;
 map.cvisit(keys.begin(), keys.end(), result.begin(), [&](const auto& x, auto& it){
 *it = x->second;
 });
 return result;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /