hashLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:4k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* hashLib.h - hash table library header */
  2. /* Copyright 1984-2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01i,23oct01,rae  undo 01h
  7. 01h,10oct01,rae  merge from truestack ver 01i base 01g
  8. 01g,22sep92,rrr  added support for c++
  9. 01f,04jul92,jcf  cleaned up.
  10. 01e,26may92,rrr  the tree shuffle
  11. 01d,04oct91,rrr  passed through the ansification filter
  12.   -changed copyright notice
  13. 01c,05oct90,shl  added ANSI function prototypes.
  14.                  made #endif ANSI style.
  15.  added copyright notice.
  16. 01b,26jun90,jcf  remove hash id error status.
  17. 01a,17nov89,jcf  written.
  18. */
  19. #ifndef __INChashLibh
  20. #define __INChashLibh
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #include "vwModNum.h"
  25. #include "sllLib.h"
  26. #include "classLib.h"
  27. #include "private/objLibP.h"
  28. /* status codes */
  29. #define S_hashLib_KEY_CLASH (M_hashLib | 1)
  30. /* type definitions */
  31. /* HIDDEN */
  32. typedef struct hashtbl /* HASH_TBL */
  33.     {
  34.     OBJ_CORE objCore; /* object management */
  35.     int elements; /* number of elements in table */
  36.     FUNCPTR keyCmpRtn; /* comparator function */
  37.     FUNCPTR keyRtn; /* hash function */
  38.     int keyArg; /* hash function argument */
  39.     SL_LIST *pHashTbl; /* pointer to hash table array */
  40.     } HASH_TBL;
  41. typedef SL_NODE HASH_NODE; /* HASH_NODE */
  42. typedef HASH_TBL *HASH_ID;
  43. /* END_HIDDEN */
  44. /* These hash nodes are used by the hashing functions in hashLib(1) */
  45. typedef struct /* H_NODE_INT */
  46.     {
  47.     HASH_NODE node; /* linked list node (must be first) */
  48.     int key; /* hash node key */
  49.     int data; /* hash node data */
  50.     } H_NODE_INT;
  51. typedef struct /* H_NODE_STRING */
  52.     {
  53.     HASH_NODE node; /* linked list node (must be first) */
  54.     char *string; /* hash node key */
  55.     int data; /* hash node data */
  56.     } H_NODE_STRING;
  57. /* class definition */
  58. IMPORT CLASS_ID hashClassId; /* hash table class id */
  59. /* function declarations */
  60. #if defined(__STDC__) || defined(__cplusplus)
  61. extern BOOL  hashKeyCmp (H_NODE_INT *pMatchHNode,
  62.     H_NODE_INT *pHNode, int keyCmpArg);
  63. extern BOOL  hashKeyStrCmp (H_NODE_STRING *pMatchHNode,
  64.        H_NODE_STRING *pHNode, int keyCmpArg);
  65. extern HASH_ID  hashTblCreate (int sizeLog2, FUNCPTR keyCmpRtn,
  66.        FUNCPTR keyRtn, int keyArg);
  67. extern HASH_NODE * hashTblEach (HASH_ID hashId, FUNCPTR routine,
  68.      int routineArg);
  69. extern HASH_NODE * hashTblFind (HASH_ID hashId, HASH_NODE *pMatchNode,
  70.      int keyCmpArg);
  71. extern STATUS  hashLibInit (void);
  72. extern STATUS  hashTblDelete (HASH_ID hashId);
  73. extern STATUS  hashTblDestroy (HASH_ID hashId, BOOL dealloc);
  74. extern STATUS  hashTblInit (HASH_TBL *pHashTbl, SL_LIST *pTblMem,
  75.      int sizeLog2, FUNCPTR keyCmpRtn,
  76.      FUNCPTR keyRtn, int keyArg);
  77. extern STATUS  hashTblPut (HASH_ID hashId, HASH_NODE *pHashNode);
  78. extern STATUS  hashTblRemove (HASH_ID hashId, HASH_NODE *pHashNode);
  79. extern STATUS  hashTblTerminate (HASH_ID hashId);
  80. extern int  hashFuncIterScale (int elements, H_NODE_STRING *pHNode,
  81.    int seed);
  82. extern int  hashFuncModulo (int elements, H_NODE_INT *pHNode,
  83. int divisor);
  84. extern int  hashFuncMultiply (int elements, H_NODE_INT *pHNode,
  85.   int multiplier);
  86. #else /* __STDC__ */
  87. extern BOOL  hashKeyCmp ();
  88. extern BOOL  hashKeyStrCmp ();
  89. extern HASH_ID  hashTblCreate ();
  90. extern HASH_NODE *hashTblEach ();
  91. extern HASH_NODE *hashTblFind ();
  92. extern STATUS  hashLibInit ();
  93. extern STATUS  hashTblDelete ();
  94. extern STATUS  hashTblDestroy ();
  95. extern STATUS  hashTblInit ();
  96. extern STATUS  hashTblPut ();
  97. extern STATUS  hashTblRemove ();
  98. extern STATUS  hashTblTerminate ();
  99. extern int  hashFuncIterScale ();
  100. extern int  hashFuncModulo ();
  101. extern int  hashFuncMultiply ();
  102. #endif /* __STDC__ */
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif /* __INChashLibh */