00001
00002 /*---------------------------------------------------------------------------
00003
00004 File name : dictionary.h
00005 Author : Nicolas Devillard
00006 Created on : August 2000
00007 Description : dictionary implements a dictionary for string variables.
00008
00009 *--------------------------------------------------------------------------*/
00010
00011 /*
00012 $Id: dictionary.h,v 1.1 2003/09/03 12:50:47 amodigli Exp $
00013 $Author: amodigli $
00014 $Date: 2003/09/03 12:50:47 $
00015 $Revision: 1.1 $
00016 */
00017
00018 #ifndef _DICTIONARY_H_
00019 #define _DICTIONARY_H_
00020
00021 /*---------------------------------------------------------------------------
00022 Includes
00023 ---------------------------------------------------------------------------*/
00024
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <unistd.h>
00029
00030
00031 /*---------------------------------------------------------------------------
00032 New types
00033 ---------------------------------------------------------------------------*/
00034
00035 typedef struct _dictionary_ {
00036 int n ;
00037 int size ;
00038 char ** val ;
00039 char ** key ;
00040 unsigned * hash ;
00041 } dictionary ;
00042
00043
00044 /*---------------------------------------------------------------------------
00045 Function prototypes
00046 ---------------------------------------------------------------------------*/
00047
00048
00049 /*-------------------------------------------------------------------------*/
00062 /*--------------------------------------------------------------------------*/
00063
00064 unsigned dictionary_hash(char * key);
00065
00066
00067 /*-------------------------------------------------------------------------*/
00079 /*--------------------------------------------------------------------------*/
00080
00081 dictionary * dictionary_new(int size);
00082
00083
00084 /*-------------------------------------------------------------------------*/
00094 /*--------------------------------------------------------------------------*/
00095
00096 void dictionary_del(dictionary * vd);
00097
00098
00099 /*-------------------------------------------------------------------------*/
00113 /*--------------------------------------------------------------------------*/
00114 char * dictionary_get(dictionary * vd, char * key);
00115
00116
00117 /*-------------------------------------------------------------------------*/
00135 /*--------------------------------------------------------------------------*/
00136
00137 void dictionary_set(dictionary * vd, char * key, char * val);
00138
00139
00140 /*-------------------------------------------------------------------------*/
00153 /*--------------------------------------------------------------------------*/
00154
00155
00156 void dictionary_setint(dictionary * d, char * key, int val);
00157
00158
00159
00160 /*-------------------------------------------------------------------------*/
00173 /*--------------------------------------------------------------------------*/
00174
00175
00176 void dictionary_setdouble(dictionary * d, char * key, double val);
00177
00178
00179
00180 /*-------------------------------------------------------------------------*/
00193 /*--------------------------------------------------------------------------*/
00194
00195 void dictionary_dump(dictionary * d, FILE * out);
00196
00197 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001