[#BloombergLP-bdlcc-StripedUnorderedMultiMap-setComputedValueFirst]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlcc.adoc[bdlcc]::xref:BloombergLP/bdlcc/StripedUnorderedMultiMap.adoc[StripedUnorderedMultiMap]::setComputedValueFirst
:relfileprefix: ../../../
:mrdocs:

Invoke `visitor` on the value of the first element matching `key`&period;

== Synopsis

Declared in `&lt;bdlcc&lowbar;stripedunorderedmultimap&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
setComputedValueFirst(
    KEY const& key,
    xref:BloombergLP/bdlcc/StripedUnorderedMultiMap/VisitorFunction.adoc[VisitorFunction] const& visitor);
----

== Description

Invoke the specified `visitor` passing the specified `key`, and the address of the value attribute of the _first_ element (of possibly many elements) found in this hash map having `key`&period; If `key` is not in the map, `value` will be default constructed&period; That is, for `(key, value)`, invoke&colon; &grave; bool visitor(VALUE &ast;value, const Key&amp; key)&semi; &grave; If no element in the map has `key`, insert `(key, VALUE())` and invoke `visitor` with `value` pointing to the default constructed value&period; Return 1 if `key` was found and `visitor` returned `true`, 0 if `key` was not found, and &hyphen;1 if `key` was found and `visitor` returned `false`&period; `visitor`, when invoked, has exclusive access (i&period;e&period;, write access) to the element&period; The behavior is undefined if hash map manipulators and `getValue&ast;` methods are invoked from within `visitor`, as it may lead to a deadlock&period; Note that the return value equals the number of elements inserted&period; Also note that, when there are multiple elements having `key`, the selection of &quot;first&quot; is implementation specific and subject to change&period; Also note that this method is more performant than the `setComputedValueAll` method when the hash map contains a single element for `key`&period; Also note that a return value of `0` implies that an element was inserted&period;

== Return Value

1 if found and visitor returned `true`, 0 if not found, and &hyphen;1 if visitor returned `false`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| key of the element to update or insert
| *visitor*
| functor invoked with the matching value
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
