home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / kpathsea / hash.h < prev    next >
C/C++ Source or Header  |  2000-01-15  |  2KB  |  66 lines

  1. /* hash.h: declarations for a hash table.
  2.  
  3. Copyright (C) 1994, 95 Karl Berry.
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  18.  
  19. #ifndef HASH_H
  20. #define HASH_H
  21.  
  22. #include <kpathsea/c-proto.h>
  23. #include <kpathsea/types.h>
  24.  
  25.  
  26. /* A single (key,value) pair.  */
  27. typedef struct hash_element_struct
  28. {
  29.   const_string key;
  30.   const_string value;
  31.   struct hash_element_struct *next;
  32. } hash_element_type;
  33.  
  34. /* The usual arrangement of buckets initialized to null.  */
  35. typedef struct
  36. {
  37.   hash_element_type **buckets;
  38.   unsigned size;
  39. } hash_table_type;
  40.  
  41. #ifdef KPSE_DEBUG
  42. /* How to print the hash results when debugging.  */
  43. extern boolean kpse_debug_hash_lookup_int;
  44. #endif
  45.  
  46. /* Create a hash table of size SIZE.  */
  47. extern hash_table_type hash_create P1H(unsigned size);
  48.  
  49. /* Insert the (KEY,VALUE) association into TABLE.  KEY may have more
  50.    than one VALUE.  Neither KEY nor VALUE is copied.  */
  51. extern void hash_insert P3H(hash_table_type *table,  const_string key,
  52.                             const_string value);
  53.  
  54. /* Remove the (KEY,VALUE) association from TABLE.  */
  55. extern void hash_remove P3H(hash_table_type *table,  const_string key,
  56.                             const_string value);
  57.  
  58. /* Look up KEY in MAP, and return NULL-terminated list of all matching
  59.    values (not copies), in insertion order.  If none, return NULL.  */
  60. extern string *hash_lookup P2H(hash_table_type table, const_string key);
  61.  
  62. /* Print TABLE to stderr.  */
  63. extern void hash_print P2H(hash_table_type table, boolean summary_only);
  64.  
  65. #endif /* not HASH_H */
  66.