1

Is there an efficient way to implement remove_if for absl::flat_hash_map?

It is my understanding that absl::flat_hash_map doesn't return the iterator to the next element, which is generally used for remove_if's implementation.

Does Abseil provide an alternative implementation for such operation?

Pretty much what I want is to iterate on the map and selectively remove items. I'm trying to avoid having a separate container to keep track of what to remove if at all possible.

bst
  • 426
  • 3
  • 10

1 Answers1

3

remove_if reorders elements, and so is inapplicable to associative containers (it has nothing to do with Abseil’s implementation). Just use std::erase_if (or absl::erase_if).

Sneftel
  • 40,271
  • 12
  • 71
  • 104