chsvlib
chsv helper source code

◆ MapFind()

EXTERN_C HCHSVMAPITERATOR Chusov::MapFind ( HCHSVMAP  hMap,
const void *  pKey,
std::size_t  cbKey 
)
noexcept

The function returns an iterator bound with an element identified by the key. In a case of the multimap with multiple elements of the same key requested by the call, the iterator of the first of them is returned. See remarks.

Parameters
[in]hMapis a handle to the map (or multimap) instance where the specified element is sought.
[in]pKeyis a pointer to the memory with key data specifying an element to be associated with the new iterator.
[in]cbKeyis a byte size of the memory pointed by the pKey.
Returns
On success the function returns a handle to the newly created iterator bound with the sought element. If there are no elements with the specified key the function returns MAP_ITERATOR_DOES_NOT_EXIST (NULL). If the function fails for any other reason it returns MAP_ITERATOR_ERROR (-1) setting appropriate last chsvlib error code which could be retrieved by calling the GetLastChsvError.
Remarks
The complexity is \(O(\log n)\).
In the case of using an instance of a multimap with multiple elements of the specified key the function returns the first of them. Use the MapIterNext and MapIterPrev functions to find an exact element within the subset of elements with the same keys.
Map iterators are just pointers to internal memory and they are not need to be closed specifically.
Declared in chsvmap.h.
See also
MapInsert;
MapIterPrev;
MapIterNext;
MapBegin;
MapEnd.