Back to index

tetex-bin  3.0
hash.h
Go to the documentation of this file.
00001 /* hash.h: declarations for a hash table.
00002 
00003 Copyright (C) 1994, 95 Karl Berry.
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Library General Public
00007 License as published by the Free Software Foundation; either
00008 version 2 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Library General Public License for more details.
00014 
00015 You should have received a copy of the GNU Library General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00018 
00019 #ifndef HASH_H
00020 #define HASH_H
00021 
00022 #include <kpathsea/c-proto.h>
00023 #include <kpathsea/types.h>
00024 
00025 
00026 /* A single (key,value) pair.  */
00027 typedef struct hash_element_struct
00028 {
00029   const_string key;
00030   const_string value;
00031   struct hash_element_struct *next;
00032 } hash_element_type;
00033 
00034 /* The usual arrangement of buckets initialized to null.  */
00035 typedef struct
00036 {
00037   hash_element_type **buckets;
00038   unsigned size;
00039 } hash_table_type;
00040 
00041 #ifdef KPSE_DEBUG
00042 /* How to print the hash results when debugging.  */
00043 extern boolean kpse_debug_hash_lookup_int;
00044 #endif
00045 
00046 /* Create a hash table of size SIZE.  */
00047 extern KPSEDLL hash_table_type hash_create P1H(unsigned size);
00048 
00049 /* Insert the (KEY,VALUE) association into TABLE.  KEY may have more
00050    than one VALUE.  Neither KEY nor VALUE is copied.  */
00051 extern KPSEDLL void hash_insert P3H(hash_table_type *table,
00052                                     const_string key,
00053                                     const_string value);
00054 
00055 /* Insert the (KEY, VALUE) association into TABLE.  KEY may have more
00056    than one VALUE.  Neither KEY nor VALUE is copied.  Assume that KEY
00057    is already normalized (all lowercase) on platforms where this matters. */
00058 extern KPSEDLL void hash_insert_normalized P3H(hash_table_type *table,
00059                                                const_string key,
00060                                                const_string value);
00061 
00062 /* Remove the (KEY,VALUE) association from TABLE.  */
00063 extern KPSEDLL void hash_remove P3H(hash_table_type *table,  const_string key,
00064                                     const_string value);
00065 
00066 /* Look up KEY in MAP, and return NULL-terminated list of all matching
00067    values (not copies), in insertion order.  If none, return NULL.  */
00068 extern KPSEDLL string *hash_lookup P2H(hash_table_type table, const_string key);
00069 
00070 /* Print TABLE to stderr.  */
00071 extern void hash_print P2H(hash_table_type table, boolean summary_only);
00072 
00073 #endif /* not HASH_H */