30 #ifndef _RTXHASHMAP_H_ 31 #define _RTXHASHMAP_H_ 35 #ifndef HASHMAPTYPENAME 36 #define HASHMAPTYPENAME OSRTHashMap 37 #define HASHMAPENTRYTYPE OSRTHashMapEntry 38 #define HASHMAPKEYTYPE void* 39 #define HASHMAPVALUETYPE void* 40 #define HASHMAPINITFUNC rtxHashMapInit 41 #define HASHMAPNEWFUNC rtxNewHashMap 42 #define HASHMAPCOPYFUNC rtxHashMapCopy 43 #define HASHMAPFREEFUNC rtxHashMapFree 44 #define HASHMAPINSERTFUNC rtxHashMapInsert 45 #define HASHMAPPUTFUNC rtxHashMapPut 46 #define HASHMAPREMOVEFUNC rtxHashMapRemove 47 #define HASHMAPSEARCHFUNC rtxHashMapSearch 48 #define HASHMAPSORTFUNC rtxHashMapSort 55 typedef struct HASHMAPENTRYTYPE {
57 HASHMAPVALUETYPE value;
59 struct HASHMAPENTRYTYPE* next;
64 HASHMAPENTRYTYPE** table;
68 OSUINT32 (*hashFunc)(HASHMAPKEYTYPE key);
69 OSBOOL (*equalsFunc)(HASHMAPKEYTYPE key1, HASHMAPKEYTYPE key2);
82 (
OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap,
size_t capacity,
83 OSUINT32 (*hashFunc)(HASHMAPKEYTYPE),
84 OSBOOL (*keyEqualsFunc)(HASHMAPKEYTYPE,HASHMAPKEYTYPE));
97 (
OSCTXT* pctxt,
size_t capacity,
98 OSUINT32 (*hashFunc)(HASHMAPKEYTYPE),
99 OSBOOL (*keyEqualsFunc)(HASHMAPKEYTYPE,HASHMAPKEYTYPE));
111 (
OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap);
140 (
OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
141 HASHMAPVALUETYPE value);
152 (HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key, HASHMAPVALUETYPE* pvalue);
164 (
OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
165 HASHMAPVALUETYPE* pvalue);
180 (
OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
181 HASHMAPVALUETYPE value);
201 int (*compareFunc)(HASHMAPKEYTYPE key1, HASHMAPKEYTYPE key2));
EXTERNRT OSBOOL HASHMAPREMOVEFUNC(OSCTXT *pctxt, HASHMAPTYPENAME *pHashMap, HASHMAPKEYTYPE key, HASHMAPVALUETYPE *pvalue)
This function removes an entry from the hash map.
EXTERNRT HASHMAPTYPENAME * HASHMAPNEWFUNC(OSCTXT *pctxt, size_t capacity, OSUINT32(*hashFunc)(HASHMAPKEYTYPE), OSBOOL(*keyEqualsFunc)(HASHMAPKEYTYPE, HASHMAPKEYTYPE))
This function creates a new hash map.
EXTERNRT int HASHMAPSORTFUNC(OSCTXT *pctxt, HASHMAPTYPENAME *pHashMap, OSRTDList *pSortedList, int(*compareFunc)(HASHMAPKEYTYPE key1, HASHMAPKEYTYPE key2))
This function sorts the hash map in ascending order using the given key compare function.
This is the main list structure.
EXTERNRT int HASHMAPINSERTFUNC(OSCTXT *pctxt, HASHMAPTYPENAME *pHashMap, HASHMAPKEYTYPE key, HASHMAPVALUETYPE value)
This function inserts an entry into the hash map.
EXTERNRT OSBOOL HASHMAPSEARCHFUNC(HASHMAPTYPENAME *pHashMap, HASHMAPKEYTYPE key, HASHMAPVALUETYPE *pvalue)
This function searches for an entry in the hash map.
Common run-time context definitions.
EXTERNRT void HASHMAPFREEFUNC(OSCTXT *pctxt, HASHMAPTYPENAME *pHashMap)
This function frees all entries within an existing hash map.
EXTERNRT HASHMAPTYPENAME * HASHMAPCOPYFUNC(OSCTXT *pctxt, HASHMAPTYPENAME *pHashMap)
This function creates a copy of an existing hash map.
EXTERNRT void HASHMAPINITFUNC(OSCTXT *pctxt, HASHMAPTYPENAME *pHashMap, size_t capacity, OSUINT32(*hashFunc)(HASHMAPKEYTYPE), OSBOOL(*keyEqualsFunc)(HASHMAPKEYTYPE, HASHMAPKEYTYPE))
This function initializes the hash map.
EXTERNRT int HASHMAPPUTFUNC(OSCTXT *pctxt, HASHMAPTYPENAME *pHashMap, HASHMAPKEYTYPE key, HASHMAPVALUETYPE value)
This function inserts/replaces an entry into the hash map.
Run-time context structure.