libcm is a C development framework with an emphasis on audio signal processing applications.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cmHashTbl.h 2.2KB

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