home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume14 / bsd-dyna-link / assoc.h < prev    next >
C/C++ Source or Header  |  1988-05-08  |  2KB  |  98 lines

  1. #ifndef ASSOC_DEFD
  2. #define ASSOC_DEFD
  3.  
  4. #include "assoc_internals.h"
  5.  
  6.  
  7. /***********************************************************************
  8. **
  9. **  See documentation in "assoc.c"
  10. **
  11. ***********************************************************************/
  12.  
  13. /*****/
  14. /* A handle on an associative memory */
  15. #define assoc_mem assoc_memory
  16.  
  17. /*****/
  18. /* Raw memory pointers from an associative memory. Do not use free() on
  19. ** them.  See assoc_free(). */
  20. #define mem_cell H_memory_cell
  21.  
  22. /*****/
  23. /***** Get unique stored string associated with a memory cell which
  24.        was returned by assoc(), assoc_lookup() or assoc_seq(). */
  25. #define string_from_cell(cell,table)  str_from_cell(cell,table)
  26.  
  27.  
  28. /*****/
  29. /***** Get memory cell associated with a string which was returned by
  30. **     string_from_cell  */
  31. #define cell_from_string(string,table) cell_from_str(string,table)
  32.  
  33.  
  34.  
  35. /*****/
  36. /***** Gets new assoc mem */
  37. assoc_mem
  38. new_assoc_mem( /* cell_size */ );
  39.  
  40.  
  41.  
  42. /*****/
  43. /***** Associates a new cell with a given string. */
  44. mem_cell
  45. assoc(/* string, table */);
  46.  
  47. /* Is like assoc, except uses counted string, rather that null-terminated */
  48. mem_cell
  49. assocn(/*string, string_length, table */);
  50.  
  51. /*****/
  52. /***** Looks for a cell previously associated with a given string */   
  53. mem_cell
  54. assoc_lookup(/* string, table */);
  55.  
  56. /* Like assoc_lookup, except uses counted string, rather than null-
  57. ** terminated string
  58. */
  59. mem_cell
  60. assocn_lookup(/* string, length, table */);
  61.  
  62.  
  63. /*****/
  64. /***** Removes a memory cell from a table */
  65. assoc_free(/* cell, table */ );
  66.  
  67. /*****/
  68. /* Sequences through a table, returning the cells found there in a 
  69. ** non-deterministic order.  If you put cells into the table as you
  70. ** are sequencing through, the sequencer may find the added value or
  71. ** it may not, so you probably do not want to do that.  Set the variable
  72. ** "seq" to zero before the first call, then don't touch it.  The
  73. ** sequencer is finished when it returns NULL;
  74. */
  75. mem_cell
  76. assoc_seq( /* table, &seq */ );
  77.  
  78.  
  79. /*****/
  80. /* Deallocates the memory associated with an assoc_mem table and returns zero,
  81. ** if the table was empty.  Otherwize it just returns the number of entries
  82. ** remaining in the table.
  83. */
  84. int
  85. assoc_mem_free( /* table */ );
  86.  
  87. /*****/
  88. /***** Empties a table, then removes it. */
  89. assoc_mem_remove(/* table */ );
  90.  
  91.  
  92.  
  93. /*****/
  94. /***** returns number of entries currently in table */
  95. #define assoc_num_entries(table) (table->entries)
  96.  
  97. #endif ASSOC_DEFD
  98.