chsvlib
chsv helper source code

◆ MapEnd()

EXTERN_C HCHSVMAPITERATOR Chusov::MapEnd ( HCHSVMAP  hMap)
noexcept

The function returns an iterator bound with the last existing map element.

Parameters
[in]hMapis a handle to a map or a multimap instance.
Returns
On success the function returns a handle to the iterator bound with the last existing element of the map. If the map is empty 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.
Warning
Unlike other existing implementations of associative arrays the range [MapBegin; MapEnd] in totally inclusive. Calling the MapIterNext function over the last existing element of the map will return MAP_ITERATOR_DOES_NOT_EXIST (NULL). Therefore the convenient implementation of any loop involving the last map item would be looked like the following:
for (HCHSVMAPITERATOR hIter = MapBegin(hMap); hIter != NULL; hIter = MapIterNext(hIter)) {}
The reverse loop can be implemented similarly:
for (HCHSVMAPITERATOR hIter = MapEnd(hMap); hIter != NULL; hIter = MapIterPrev(hIter)) {}
Remarks
Map iterators are just pointers to internal memory and they are not need to be closed specifically.
The complexity is \(O(1)\).
Declared in chsvmap.h.
See also
MapBegin;
MapIterPrev;
MapIterNext.