Invoke visitor on the value for key, inserting a default if absent.
Synopsis
Declared in <bdlcc_stripedunorderedmap.h>
int
setComputedValue(
KEY const& key,
VisitorFunction const& visitor);
Description
The visitor will be passed the address of the value, and key. If key is not in the map, value will be default constructed. That is, visitor must be invocable with the VisitorFunction signature: ` bool visitor(VALUE *value, const Key& key); ` If no element in the map has key, insert (key, VALUE()) and invoke visitor with value pointing to the default constructed value. Return 1 if key was found and visitor returned true, 0 if key was not found, and ‐1 if key was found and visitor returned false. visitor, when invoked, has exclusive access (i.e., write access) to the element. The behavior is undefined if hash map manipulators and getValue* methods are invoked from within visitor, as it may lead to a deadlock. Note that the return value equals the number of elements found having key. Also note that a return value of 0 implies that an element was inserted.
Return Value
1 if found and visitor returned true, 0 if not found, and ‐1 if visitor returned false
Parameters
Name |
Description |
key |
key of the element to visit or insert |
visitor |
functor invoked with the address of the value |
Created with MrDocs