Skip to content

Commit

Permalink
Add comment on how to get next element after using erase.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696930388
Change-Id: I7bd45c8a80458a84826a85392106d18833901154
  • Loading branch information
Abseil Team authored and copybara-github committed Nov 15, 2024
1 parent 8f739d1 commit e3cf5b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions absl/container/node_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,13 @@ class ABSL_ATTRIBUTE_OWNER node_hash_map
// Erases the element at `position` of the `node_hash_map`, returning
// `void`.
//
// NOTE: this return behavior is different than that of STL containers in
// general and `std::unordered_map` in particular.
// NOTE: Returning `void` in this case is different than that of STL
// containers in general and `std::unordered_map` in particular (which
// return an iterator to the element following the erased element). If that
// iterator is needed, simply post increment the iterator:
//
// map.erase(it++);
//
//
// iterator erase(const_iterator first, const_iterator last):
//
Expand Down
9 changes: 7 additions & 2 deletions absl/container/node_hash_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,13 @@ class ABSL_ATTRIBUTE_OWNER node_hash_set
// Erases the element at `position` of the `node_hash_set`, returning
// `void`.
//
// NOTE: this return behavior is different than that of STL containers in
// general and `std::unordered_set` in particular.
// NOTE: Returning `void` in this case is different than that of STL
// containers in general and `std::unordered_map` in particular (which
// return an iterator to the element following the erased element). If that
// iterator is needed, simply post increment the iterator:
//
// map.erase(it++);
//
//
// iterator erase(const_iterator first, const_iterator last):
//
Expand Down

0 comments on commit e3cf5b3

Please sign in to comment.