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.

cmDList.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef cmDList_h
  2. #define cmDList_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"Dynamic generic array with user programmable indexing and sorting capablity." kw:[container] }
  7. enum
  8. {
  9. kOkDlRC = cmOkRC,
  10. kDuplicateIndexIdDlRC,
  11. kInvalidIndexDlRC,
  12. kIterNotFoundDlRC,
  13. kDataRecdNotFoundDlRC,
  14. };
  15. typedef unsigned cmDlRC_t;
  16. typedef cmHandle_t cmDListH_t;
  17. typedef cmHandle_t cmDListIterH_t;
  18. extern cmDListH_t cmDListNullHandle;
  19. extern cmDListIterH_t cmDListIterNullHandle;
  20. // Return < 0 if v0 < v1
  21. // == 0 if v0 == v1
  22. // > 0 if v0 > v1
  23. typedef int (*cmDListCmpFunc_t)( void* arg, const void* v0, unsigned v0N, const void* v1, unsigned v1N );
  24. typedef void (*cmDListIndexFreeFunc_t)( unsigned indexId, void* arg );
  25. // If 'cmpFunc' is not NULL then a default index with an indexId==0 will be automatically created.
  26. cmDlRC_t cmDListAlloc( cmCtx_t* ctx, cmDListH_t* hp, cmDListCmpFunc_t cmpFunc, void* funcArg );
  27. cmDlRC_t cmDListFree( cmDListH_t* hp );
  28. bool cmDListIsValid( cmDListH_t h );
  29. // Set resyncFl to automatically update the indexes to reflect the new record, otherwise
  30. // cmDListIndexUpdateAll() should be called to resynchronize the data list to the indexes.
  31. // If many inserts are to be performed with no intervening accesses to the list then it
  32. // is more efficient to defer updating the indexes until all the inserts are completed.
  33. cmDlRC_t cmDListInsert( cmDListH_t h, const void* recd, unsigned recdByteN, bool resyncFl );
  34. // Delete a data record.
  35. // 'recd' should be set to a value returned via one of the iterator accessors.
  36. // If 'resyncFl' is set then the indexes and interators will be
  37. // automatically synchronized with the data list after the deletion.
  38. // If 'resyncFl' is not set then the client must call cmDListIndexUpdateAll()
  39. // to resynchronize the indexes and iterators after the deletion.
  40. // Note that if multiple records are to be deleted without intervening accesses
  41. // to the list then it is more efficient to defer update the indexes until
  42. // all the deletions are completed.
  43. cmDlRC_t cmDListDelete( cmDListH_t h, const void* recd, bool resyncFl );
  44. // Allocate a new index. 'indexId' is used to identify this index and must be unique among all
  45. // previously allocated indexes.
  46. cmDlRC_t cmDListIndexAlloc( cmDListH_t h, unsigned indexId, cmDListCmpFunc_t cmpFunc, void* funcArg );
  47. cmDlRC_t cmDListIndexFree( cmDListH_t h, unsigned indexId );
  48. // Refresh all the indexes. This function should be called after new records are inserted
  49. // via cmDListInsert(..,false).
  50. cmDlRC_t cmDListIndexUpdateAll( cmDListH_t h );
  51. // Set a function to be called when indexes are released.
  52. cmDlRC_t cmDListIndexSetFreeFunc(cmDListH_t h, unsigned indexId, cmDListIndexFreeFunc_t func );
  53. // Allocate an interator. By default the new iterator is pointing to the first record
  54. // in the index identified by 'indexId'.
  55. cmDlRC_t cmDListIterAlloc( cmDListH_t h, cmDListIterH_t* iHp, unsigned indexId );
  56. cmDlRC_t cmDListIterFree( cmDListIterH_t* iHp );
  57. bool cmDListIterIsValid( cmDListIterH_t iH );
  58. // Set the current iteration location to the begin/end of the index it is attached to.
  59. cmDlRC_t cmDListIterSeekBegin( cmDListIterH_t iH );
  60. cmDlRC_t cmDListIterSeekEnd( cmDListIterH_t iH );
  61. // Return the current record this iterator is pointing to.
  62. const void* cmDListIterGet( cmDListIterH_t iH, unsigned* recdByteNRef );
  63. // Return the current record this iterator is pointint to and advance the iterator.
  64. const void* cmDListIterPrev( cmDListIterH_t iH, unsigned* recdByteNRef );
  65. const void* cmDListIterNext( cmDListIterH_t iH, unsigned* recdByteNRef );
  66. // Make the record which matches 'key' the current iterator.
  67. // The match is made by using the compare function which is assigned to the index
  68. // which this iterator is attached to.
  69. const void* cmDListIterFind( cmDListIterH_t iH, const void* key, unsigned keyN, unsigned* recdByteNRef);
  70. //)
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif