home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-base.tgz / octave-1.1.1p1-base.tar / fsf / octave / kpathsea / hash.h < prev    next >
C/C++ Source or Header  |  1994-03-04  |  2KB  |  59 lines

  1. /* hash.h: declarations for a hash table.
  2.  
  3. Copyright (C) 1994 Karl Berry.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program 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
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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.  
  42. /* Create a hash table of size SIZE.  */
  43. extern hash_table_type hash_create P1H(unsigned size);
  44.  
  45. /* Look up KEY in MAP, and return a null-terminated list of all matching
  46.    entries.  If none, return NULL.  The list can be freed, but the
  47.    elements in the list are the actual values in the hash table.  */
  48. extern string *hash_lookup P2H(hash_table_type table, const_string key);
  49.  
  50. /* Insert the (KEY,VALUE) association into TABLE.  KEY may have more
  51.    than one VALUE.  */
  52. extern void hash_insert P3H(hash_table_type *table,  const_string key,
  53.                             const_string value);
  54.  
  55. /* Print TABLE to stdout.  */
  56. extern void hash_print P1H(hash_table_type table);
  57.  
  58. #endif /* not HASH_H */
  59.