BloombergLP::bslstl::HashTable::tryEmplace

Emplace a value for key if missing; otherwise return the existing entry.

Synopsis

Declared in <bslstl_hashtable.h>

template<class... ARGS>
bslalg::BidirectionalLink*
tryEmplace(
    bool* isInsertedFlag,
    bslalg::BidirectionalLink* hint,
    KeyType const& key,
    ARGS&&... args);

Description

If a key equivalent to the specified key already exists in this hash-table, load false into the specified isInsertedFlag and return a pointer to the existing entry. Otherwise, insert into this hash-table a newly-created value_type object, constructed from key and the specified args, load true into isInsertedFlag and return a pointer to the newly created entry. Use the optionally specified hint as a starting place for the search for the existing key.

Return Value

pointer to the existing or newly created entry

Parameters

NameDescription
isInsertedFlagset to true if a new entry was inserted
hintoptional starting node for the key search
keykey used to find or insert an entry
argsarguments used to construct the mapped value