Concurrent Operations: find, insert, erase

The operations find, insert, and erase are the only operations that may be concurrently invoked on the same concurrent_hash_map. These operations search the table for a key-value pair that matches a given key. The find and insert methods each have two variants. One takes a const_accessor argument and provides read-only access to the desired key-value pair. The other takes an accessor argument and provides write access.

Warning

If the non-const variant succeeds in finding the key, the consequent write access blocks any other thread from accessing the key until the accessor object is destroyed. Where possible, use the const variant to improve concurrency.

The result of the map operation is true if the operation succeeds.

bool find( const_accessor&result, const Key& key )const

Effects: searches a table for a pair with the given key. If the key is found, provides read-only access to the matching pair.

Returns: true if the key is found; false if the key is not found.

bool find( accessor& result, const Key& key )

Effects: searches a table for a pair with the given key. If the key is found, provides write access to the matching pair.

Returns: true if the key is found; false if the key is not found.

bool insert( const_accessor& result, const Key& key )

Effects: searches a table for a pair with the given key. If not present, inserts a new pair into the table. The new pair is initialized with pair(key,T()). Provides read-only access to the matching pair.

Returns: true if a new pair is inserted; false if the key is already in the map.

bool insert( accessor& result, constKey& key )

Effects: searches a table for a pair with the given key. If not present, inserts a new pair into the table. The newpair is initialized with pair(key, T()). Provides write access to the matching pair.

Returns: true if a new pair is inserted; false if the key is already in the map.

bool erase( const Key& key )

Effects: searches a table for a pair with the given key. Removes the matching pair if it exists.

Returns: true if the pair is removed; false if the key is not in the map.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.190.93