libcm is a C development framework with an emphasis on audio signal processing applications.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

cmHashTbl.h 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef cmHashTbl_h
  2. #define cmHashTbl_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"Hash table for storing arbitary data blobs." kw:[container]}
  7. enum
  8. {
  9. kOkHtRC,
  10. kLHeapFailHtRC,
  11. kHashFaultHtRC,
  12. kInvalidIdHtRC
  13. };
  14. typedef cmRC_t cmHtRC_t;
  15. typedef cmHandle_t cmHashTblH_t;
  16. extern cmHashTblH_t cmHashTblNullHandle;
  17. cmHtRC_t cmHashTblCreate( cmCtx_t* ctx, cmHashTblH_t* hp, unsigned bucketCnt );
  18. cmHtRC_t cmHashTblDestroy( cmHashTblH_t* hp );
  19. bool cmHashTblIsValid( cmHashTblH_t h );
  20. // cmhashTblStoreBase() is the canonical store function.
  21. // Set 'staticFl' to true if the value does not need to be reallocated
  22. // and copied into the internal storage space.
  23. // Returns a value which uniquely identifies the value. If a unique
  24. // identifier cannot be generated then the function returns cmInvalidId
  25. // and sets the hash table error code to kHashFaultRC.
  26. unsigned cmHashTblStoreBase( cmHashTblH_t h, void* v, unsigned byteCnt, bool staticFl );
  27. unsigned cmHashTblStore( cmHashTblH_t h, void* v, unsigned byteCnt );
  28. unsigned cmHashTblStoreStatic( cmHashTblH_t h, void* v, unsigned byteCnt );
  29. unsigned cmHashTblStoreStr( cmHashTblH_t h, const cmChar_t* s );
  30. unsigned cmhashTblStoreStaticStr( cmHashTblH_t h, const cmChar_t* s );
  31. unsigned cmHashTblStoreV( cmHashTblH_t h, const cmChar_t* fmt, va_list vl );
  32. unsigned cmHashTblStoreF( cmHashTblH_t h, const cmChar_t* fmt, ... );
  33. // Given a value find an id.
  34. unsigned cmHashTblId( cmHashTblH_t h, const void* value, unsigned byteCnt );
  35. unsigned cmHashTblStrToId( cmHashTblH_t h, const cmChar_t* str );
  36. // Returns NULL if no value is associated with 'id'.
  37. // 'byteCntRef' is optional.
  38. const void* cmHashTblValue( cmHashTblH_t h, unsigned id, unsigned* byteCntRef );
  39. // Wrapper around cmHashTblValue() which assumes that the stored value is a
  40. // zero terminated string.
  41. const cmChar_t* cmHashTblStr( cmHashTblH_t h, unsigned id );
  42. // Remove a value.
  43. cmHtRC_t cmHashTblRemove( cmHashTblH_t h, unsigned id );
  44. // Return the last error id generated by the cmHashTbl object.
  45. cmHtRC_t cmHashTblLastRC( cmHashTblH_t h );
  46. void cmHashTblReport( cmHashTblH_t h, cmRpt_t* rpt );
  47. cmHtRC_t cmHashTblTest( cmCtx_t* ctx );
  48. //)
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif