Main Page   Data Structures   File List   Data Fields   Globals  

mperfl.h

Go to the documentation of this file.
00001 /* mperf - My Perfect Hash generates fast lookup-tables.
00002  * Copyright (C) 2002 Marcus Perlick
00003  * mailto: riffraff@users.sourceforge.net
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program 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
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018  * 02111-1307, USA.  */
00019 #ifndef _MPERFL_H_
00020 #define _MPERFL_H_
00021 
00022 #include <stdlib.h>
00023 
00024 struct sNode;
00025 
00028 typedef struct {
00029   double p;
00030   const char *str;
00031   void *value;
00032 } KeyString;
00033 
00034 typedef struct {
00035   size_t keyNo;
00036   KeyString **keys;
00037 } SSizedKeys;
00038 
00039 typedef struct {
00040   size_t column;
00041   unsigned char idxBegin;
00042   unsigned char idxEnd;
00043  
00044   struct sNode **swNodes;
00045 } Switch;
00046 
00047 typedef enum {
00048   NT_KEYS,
00049   NT_SWITCH,
00050   NT_FINAL
00051 } NodeType;
00052 
00053 typedef struct sNode {
00054   NodeType type;
00055   union {
00056     SSizedKeys keys;
00057     Switch sw;
00058     KeyString *key;
00059   } v;
00060 } Node;
00061 
00062 typedef struct {
00063   size_t maxLen;
00064   Node **nodes;
00065 } MPerf;
00066 
00069 MPerf* mperf_ctor( MPerf *mp );
00070 
00073 void mperf_dtor( MPerf *mp );
00074 
00078 MPerf* mperf_init( MPerf *mp, KeyString *keys, size_t keyNo );
00079 
00082 int mperf_finish( MPerf *mp );
00083 #define ERR_DUPKEY 1
00084 
00087 KeyString *mperf_find( MPerf *mp, const char *key, size_t keyLen );
00088 
00091 KeyString *mperf_search( MPerf *mp, const char *key, size_t keyLen );
00092 
00095 int mperf_for_all( MPerf *mp,
00096            int(*fnctn)(KeyString*, void*),
00097            void *data );
00098 
00099 #endif /* _MPERFL_H_ */

Generated at Wed Oct 9 23:29:05 2002 for mperf by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001