chsvlib
chsv helper source code

◆ MapInsertByPtr()

EXTERN_C bool Chusov::MapInsertByPtr ( HCHSVMAP  hMap,
const void *  pKey,
std::size_t  cbKey,
void *  pValue 
)
noexcept

Inserts a new element by pointer. Only the pointers to the key and value data are stored, pointed memory is neither managed or freed by the map.

Parameters
[in]hMapis a handle to a map or a multimap instance.
[in]pKeyis a pointer to the key data to identify the element. The key data is not stored to the internal buffers of the element. Access to the key is performed directly using the pointer, memory management is to be performed by the caller. If hMap is an instance of a map, and not multimap, the key value must be unique among the map elements or the function will fail with the CHSVERROR_ALREADY_EXISTS code.
[in]cbKeyis a byte size of the key pointed by the pKey.
[in]pValueis a pointer to the value data of the element. The value data is not stored to the internal buffers of the element. Access to the value is performed directly using the pointer, memory management is to be performed by the caller. The pointer may be NULL.
Returns
The function returns true on successful insertion and false on failure. Use GetLastChsvError function to get the extended error information.
Remarks
The function guarantees the content of the value pointer will not be modified by the map implementation, value data itself will be ignored.
The complexity is \(O(\log n)=O_{find}(\log n)+O_{create}(1)\).
Declared in chsvmap.h.
See also
MapInsert;
MapErase.