rtxHashMap.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00030 #ifndef _RTXHASHMAP_H_
00031 #define _RTXHASHMAP_H_
00032 
00033 #include "rtxsrc/rtxContext.h"
00034 
00035 #ifndef HASHMAPTYPENAME
00036 #define HASHMAPTYPENAME   OSRTHashMap
00037 #define HASHMAPENTRYTYPE  OSRTHashMapEntry
00038 #define HASHMAPKEYTYPE    void*
00039 #define HASHMAPVALUETYPE  void*
00040 #define HASHMAPINITFUNC   rtxHashMapInit
00041 #define HASHMAPNEWFUNC    rtxNewHashMap
00042 #define HASHMAPCOPYFUNC   rtxHashMapCopy
00043 #define HASHMAPFREEFUNC   rtxHashMapFree
00044 #define HASHMAPINSERTFUNC rtxHashMapInsert
00045 #define HASHMAPPUTFUNC    rtxHashMapPut
00046 #define HASHMAPREMOVEFUNC rtxHashMapRemove
00047 #define HASHMAPSEARCHFUNC rtxHashMapSearch
00048 #define HASHMAPSORTFUNC   rtxHashMapSort
00049 #endif
00050 
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054 
00055 typedef struct HASHMAPENTRYTYPE {
00056    HASHMAPKEYTYPE key;
00057    HASHMAPVALUETYPE value;
00058    OSUINT32 hashCode;
00059    struct HASHMAPENTRYTYPE* next;
00060 } HASHMAPENTRYTYPE;
00061 
00062 typedef struct {
00063    OSUINT32 tableLength;
00064    HASHMAPENTRYTYPE** table;
00065    OSUINT32 entryCount;
00066    OSUINT32 loadLimit;
00067    OSUINT32 primeIndex;
00068    OSUINT32 (*hashFunc)(HASHMAPKEYTYPE key);
00069    OSBOOL (*equalsFunc)(HASHMAPKEYTYPE key1, HASHMAPKEYTYPE key2);
00070 } HASHMAPTYPENAME;
00071 
00081 EXTERNRT void HASHMAPINITFUNC
00082 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, size_t capacity,
00083  OSUINT32 (*hashFunc)(HASHMAPKEYTYPE),
00084  OSBOOL (*keyEqualsFunc)(HASHMAPKEYTYPE,HASHMAPKEYTYPE));
00085 
00096 EXTERNRT HASHMAPTYPENAME* HASHMAPNEWFUNC
00097 (OSCTXT* pctxt, size_t capacity,
00098  OSUINT32 (*hashFunc)(HASHMAPKEYTYPE),
00099  OSBOOL (*keyEqualsFunc)(HASHMAPKEYTYPE,HASHMAPKEYTYPE));
00100 
00110 EXTERNRT HASHMAPTYPENAME* HASHMAPCOPYFUNC
00111 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap);
00112 
00120 EXTERNRT void HASHMAPFREEFUNC (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap);
00121 
00139 EXTERNRT int HASHMAPINSERTFUNC
00140 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
00141  HASHMAPVALUETYPE value);
00142 
00151 EXTERNRT OSBOOL HASHMAPSEARCHFUNC
00152 (HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key, HASHMAPVALUETYPE* pvalue);
00153 
00163 EXTERNRT OSBOOL HASHMAPREMOVEFUNC
00164 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
00165  HASHMAPVALUETYPE* pvalue);
00166 
00179 EXTERNRT int HASHMAPPUTFUNC
00180 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, HASHMAPKEYTYPE key,
00181  HASHMAPVALUETYPE value);
00182 
00199 EXTERNRT int HASHMAPSORTFUNC
00200 (OSCTXT* pctxt, HASHMAPTYPENAME* pHashMap, OSRTDList* pSortedList,
00201  int (*compareFunc)(HASHMAPKEYTYPE key1, HASHMAPKEYTYPE key2));
00202 
00203 #ifdef __cplusplus
00204 }
00205 #endif
00206 
00207 #endif