chsvlib
chsv helper source code
Associative array (map)

The C functions over an associative array implemented as a binary tree. More...

Macros

#define MAP_ITERATOR_ERROR   ((NS_CHUSOV HCHSVMAPITERATOR) -1)
 Service map iterator value indicating a system error.
 
#define MAP_ITERATOR_DOES_NOT_EXIST   ((NS_CHUSOV HCHSVMAPITERATOR) 0)
 Service map iterator value indicating that a specified element has not been found.
 

Typedefs

typedef int(* PMAPCOMPAREFUNC) (const void *pLeft, std::size_t cbLeft, const void *pRight, std::size_t cbRight) NOEXCEPT_CPP17
 A pointer to a compare function implementing a binary predicate over data in buffers pointed by the function parameters. More...
 
typedef bool(* PMAPELEMENTFUNCTION) (const void *pKey, std::size_t cbKey, void *pValue, std::size_t cbValue, void *lpArg) NOEXCEPT_CPP17
 A client callback function used in the MapApplyFuncToElements function as a procedure over each element of the map. More...
 

Functions

EXTERN_C HCHSVMAP CreateMapEx (PMAPCOMPAREFUNC pfnCompare, bool fMultimap) noexcept
 Creates an instance of a map or a multimap. More...
 
EXTERN_C HCHSVMAP CreateMap () noexcept
 Creates a map with the default ordering towards growth of keys with the requirement for the keys to be unique. More...
 
EXTERN_C HCHSVMAP CreateMultimapEx (PMAPCOMPAREFUNC pfnCompare) noexcept
 Creates a multimap with the specified ordering predicate. More...
 
EXTERN_C HCHSVMAP CreateMultimap () noexcept
 Creates a multimap with the default ordering of map elements towards growth of their keys . More...
 
EXTERN_C bool CloseMap (HCHSVMAP hMap) noexcept
 Closes an instance of a map or a multimap freeing occupied resources. More...
 
EXTERN_C bool MapInsert (HCHSVMAP hMap, const void *pKey, std::size_t cbKey, const void *pValue, std::size_t cbValue) noexcept
 Inserts a new element by value to the specified map. The data in the parameter is copied into the internal buffers bound to elements. More...
 
EXTERN_C bool 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. More...
 
EXTERN_C HCHSVMAPITERATOR 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. More...
 
EXTERN_C HCHSVMAPITERATOR MapBegin (HCHSVMAP hMap) noexcept
 The function returns an iterator bound with the first map element. More...
 
EXTERN_C HCHSVMAPITERATOR MapEnd (HCHSVMAP hMap) noexcept
 The function returns an iterator bound with the last existing map element. More...
 
EXTERN_C HCHSVMAPITERATOR MapIterPrev (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns an iterator preceding the specified one or NULL if there are no preceding elements. More...
 
EXTERN_C HCHSVMAPITERATOR MapIterNext (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns an iterator following the specified one or NULL if there are no following elements. More...
 
EXTERN_C bool MapErase (HCHSVMAP hMap, HCHSVMAPITERATOR hWhere) noexcept
 The function removes an element specified by the iterator from the map. More...
 
EXTERN_C std::size_t MapGetSize (HCHSVMAP hMap) noexcept
 The function returns a number of elements the map contains. More...
 
EXTERN_C const void * MapGetKeyFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a pointer to key data of the specified element. More...
 
EXTERN_C void * MapGetDataFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a pointer to value data of the specified element. More...
 
EXTERN_C std::size_t MapGetKeySizeFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a length, in bytes, of the key of the specified element. More...
 
EXTERN_C std::size_t MapGetDataSizeFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a length, in bytes, of value data of the specified element inserted by value (with copying) or zero if the element has been inserted by pointer. More...
 
EXTERN_C bool MapApplyFuncToElements (HCHSVMAP hMap, PMAPELEMENTFUNCTION lpfnCallback, void *lpCallbackArg)
 The function implements calling the specified callback function called over each element of the map. More...
 

Detailed Description

The C functions over an associative array implemented as a binary tree.