ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgflib/lookup.h
(Generate patch)

Comparing ray/src/cv/mgflib/lookup.h (file contents):
Revision 1.7 by greg, Mon Jun 24 09:14:36 1996 UTC vs.
Revision 1.12 by schorsch, Sat Nov 15 17:54:06 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   * Header file for general associative table lookup routines
4   */
5 + #ifndef _RAD_LOOKUP_H_
6 + #define _RAD_LOOKUP_H_
7  
8 + #include <string.h> /* strcmp() */
9 +
10 + #ifdef __cplusplus
11 + extern "C" {
12 + #endif
13 +
14 + typedef void lut_free_t(void*);
15 +
16   typedef struct {
17 <        char    *key;           /* key name */
18 <        long    hval;           /* key hash value (for efficiency) */
19 <        char    *data;          /* pointer to client data */
17 >        char    *key;                   /* key name */
18 >        unsigned long   hval;           /* key hash value (for efficiency) */
19 >        char    *data;                  /* pointer to client data */
20   } LUENT;
21  
15 #ifdef NOPROTO
22   typedef struct {
23 <        long    (*hashf)();     /* key hash function */
24 <        int     (*keycmp)();    /* key comparison function */
25 <        void    (*freek)();     /* free a key */
26 <        void    (*freed)();     /* free the data */
27 <        int     tsiz;           /* current table size */
28 <        LUENT   *tabl;          /* table, if allocated */
29 <        int     ndel;           /* number of deleted entries */
23 >        unsigned long (*hashf)(char*);  /* key hash function */
24 >        int (*keycmp)(const char*, const char*);        /* key comparison function */
25 >        lut_free_t *freek;              /* free a key */
26 >        lut_free_t *freed;              /* free the data */
27 >        int     tsiz;                   /* current table size */
28 >        LUENT   *tabl;                  /* table, if allocated */
29 >        int     ndel;                   /* number of deleted entries */
30   } LUTAB;
25 #else
26 typedef struct {
27        long    (*hashf)();     /* key hash function */
28        int     (*keycmp)(const char *, const char *);  /* key comparison function */
29        void    (*freek)(char *);       /* free a key */
30        void    (*freed)(char *);       /* free the data */
31        int     tsiz;           /* current table size */
32        LUENT   *tabl;          /* table, if allocated */
33        int     ndel;           /* number of deleted entries */
34 } LUTAB;
35 #endif
31  
32 < #define LU_SINIT(fk,fd)         {lu_shash,strcmp,(void (*)())(fk),\
33 <                                (void (*)())(fd),0,NULL,0}
32 > #undef strcmp
33 > #define LU_SINIT(fk,fd)         {lu_shash,strcmp,fk,\
34 >                                fd,0,NULL,0}
35  
36   /*
37   * The lu_init routine is called to initialize a table.  The number of
# Line 71 | Line 67 | typedef struct {
67   * It is therefore an error to reuse or do anything with the key
68   * field after calling lu_delete.
69   *
70 + * The lu_doall routine loops through every filled table entry, calling
71 + * the given function once on each entry.  If a NULL pointer is passed
72 + * for this function, then lu_doall simply returns the total number of
73 + * active entries.  Otherwise, it returns the sum of all the function
74 + * evaluations.
75 + *
76   * The lu_done routine calls the given free function once for each
77   * assigned table entry (i.e. each entry with an assigned key value).
78   * The user must define these routines to free the key and the data
# Line 78 | Line 80 | typedef struct {
80   * allocated table itself.
81   */
82  
83 < #ifdef NOPROTO
84 < extern int      lu_init();
85 < extern LUENT    *lu_find();
86 < extern void     lu_delete();
87 < extern void     lu_done();
88 < extern long     lu_shash();
89 < extern int      strcmp();
90 < #else
91 < extern int      lu_init(LUTAB *, int);
92 < extern LUENT    *lu_find(LUTAB *, char *);
91 < extern void     lu_delete(LUTAB *, char *);
92 < extern void     lu_done(LUTAB *);
93 < extern long     lu_shash(char *);
94 < extern int      strcmp(char *, char *);
83 > extern int      lu_init(LUTAB *tbl, int nel);
84 > extern unsigned long    lu_shash(char *s);
85 > extern LUENT    *lu_find(LUTAB *tbl, char *key);
86 > extern void     lu_delete(LUTAB *tbl, char *key);
87 > extern int      lu_doall(LUTAB *tbl, int (*f)(LUENT*));
88 > extern void     lu_done(LUTAB *tbl);
89 >
90 >
91 > #ifdef __cplusplus
92 > }
93   #endif
94 + #endif /* _RAD_LOOKUP_H_ */
95 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines