chsvlib
chsv helper source code

◆ CreateMapEx()

EXTERN_C HCHSVMAP Chusov::CreateMapEx ( PMAPCOMPAREFUNC  pfnCompare,
bool  fMultimap 
)
noexcept

Creates an instance of a map or a multimap.

Parameters
[in]pfnCompareis an optional pointer to a function of the PMAPCOMPAREFUNC type. The function must implement a binary predicate used to compare and order elements by their keys. If the parameter is NULL the default predicate is used. That is a check if the first element is less than the second one. See remarks for the description of 'less' term.
[in]fMultimapflag defines if the elements of the map must have unique keys. I.e. if the flag is true flag the keys must be unique throughout all elements of one instance of the map.If the flag is not set then multiple map elements are allowed to contain the same key. This is the case of a so called multimap.
Returns
The function returns a handle to an instance of the created map. If the function fails it returns NULL. Use GetLastChsvError to get extended error information. information.
Remarks
The default compare function is defined as follows. Let \(K_1=\left\{b_0^{K_1},...b_{L_1 - 1}^{K_1}\right\}\) be a key of the first map element which is an ordered set of bytes \(b^{K_1}\) and let \(K_2=\left\{b_{0}^{K_2},...,b_{L_2 - 1}^{K_2}\right\}\) be a key of the second element consisting of bytes \(b^{K_2}\). Then for \(m=\mathrm{min}\left(L_1,L_2\right)\) and \(e:\forall i\in\left[0,e-1\right]\Rightarrow b_{i}^{K_1}=b_{i}^{K_2}\) the function returns:\
  • negative integer if \(\left( e<m\land b_e^{K_1}<b_e^{K_2}\right) \lor\left( e=m\land L_1<L_2\right) \) ("less");
  • zero if \(e=m=L_1=L_2\) ("equal");
  • positive integer if \(\left( e<m\land b_e^{K_1}>b_e^{K_2}\right) \lor\left( e=m\land L_1>L_2\right) \) ("greater").
Declared in chsvmap.h.