XBinder  Version 2.6.x
rtxHashMap.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
30 #ifndef _RTXHASHMAP_H_
31 #define _RTXHASHMAP_H_
32 
33 #include "rtxsrc/rtxContext.h"
34 
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
49 #endif
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 typedef struct HASHMAPENTRYTYPE {
56  HASHMAPKEYTYPE key;
57  HASHMAPVALUETYPE value;
58  OSUINT32 hashCode;
59  struct HASHMAPENTRYTYPE* next;
60 } HASHMAPENTRYTYPE;
61 
62 typedef struct {
63  OSUINT32 tableLength;
64  HASHMAPENTRYTYPE** table;
65  OSUINT32 entryCount;
66  OSUINT32 loadLimit;
67  OSUINT32 primeIndex;
68  OSUINT32 (*hashFunc)(HASHMAPKEYTYPE key);
69  OSBOOL (*equalsFunc)(HASHMAPKEYTYPE key1, HASHMAPKEYTYPE key2);
70 } HASHMAPTYPENAME;
71 
81 EXTERNRT void HASHMAPINITFUNC
82 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, size_t capacity,
83  OSUINT32 (*hashFunc)(HASHMAPKEYTYPE),
84  OSBOOL (*keyEqualsFunc)(HASHMAPKEYTYPE,HASHMAPKEYTYPE));
85 
96 EXTERNRT HASHMAPTYPENAME* HASHMAPNEWFUNC
97 (OSCTXT* pctxt, size_t capacity,
98  OSUINT32 (*hashFunc)(HASHMAPKEYTYPE),
99  OSBOOL (*keyEqualsFunc)(HASHMAPKEYTYPE,HASHMAPKEYTYPE));
100 
110 EXTERNRT HASHMAPTYPENAME* HASHMAPCOPYFUNC
111 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap);
112 
120 EXTERNRT void HASHMAPFREEFUNC (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap);
121 
139 EXTERNRT int HASHMAPINSERTFUNC
140 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
141  HASHMAPVALUETYPE value);
142 
151 EXTERNRT OSBOOL HASHMAPSEARCHFUNC
152 (HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key, HASHMAPVALUETYPE* pvalue);
153 
163 EXTERNRT OSBOOL HASHMAPREMOVEFUNC
164 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
165  HASHMAPVALUETYPE* pvalue);
166 
179 EXTERNRT int HASHMAPPUTFUNC
180 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
181  HASHMAPVALUETYPE value);
182 
199 EXTERNRT int HASHMAPSORTFUNC
200 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, OSRTDList* pSortedList,
201  int (*compareFunc)(HASHMAPKEYTYPE key1, HASHMAPKEYTYPE key2));
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif
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.
Definition: rtxDList.h:64
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.
Definition: rtxContext.h:185