typedef concurrent_hash_mapMapT; MapT m;m.insert(make_pair(1,0));MapT::accessor a;m.find(a, 1);// Assuming 1 was foundm.erase(1);
m.erase(a);
Link Copied
Searches table for pair with given key. Removes the matching pair if it exists. If thereis an accessor pointing to the pair, the pair is nonetheless removed from the table butits destruction is deferred until all accessors stop pointing to it.
Removes pair referenced by item_accessor. Concurrent insertion of the same keycreates a new pair in the table.Removes pair referenced by item_accessor. Concurrent insertion of the same key creates a new pair in the table.
CAUTION: Though there can be at most one occurrence of a given key in the map, there may beother key-value pairs in flight with the same key. These arise from the semantics of theinsert and erase methods. The insert methods can create and destroy a temporarykey-value pair that is not inserted into a map. The erase methods remove a key-valuepair from the map before destroying it, thus permitting another thread to construct asimilar key before the old one is destroyed.
For more complete information about compiler optimizations, see our Optimization Notice.