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

Comparing ray/src/common/lookup.h (file contents):
Revision 2.2 by greg, Thu Jul 7 14:02:31 1994 UTC vs.
Revision 2.13 by greg, Tue May 25 06:30:46 2004 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 *p);
15 + typedef unsigned long lut_hashf_t(void*);
16 + typedef int lut_keycmpf_t(const void*, const void*);
17 +
18   typedef struct {
19 <        char    *key;           /* key name */
20 <        long    hval;           /* key hash value (for efficiency) */
21 <        char    *data;          /* pointer to client data */
19 >        char    *key;                   /* key name */
20 >        unsigned long   hval;           /* key hash value (for efficiency) */
21 >        char    *data;                  /* pointer to client data */
22   } LUENT;
23  
24   typedef struct {
25 <        long    (*hashf)();     /* key hash function */
26 <        int     (*keycmp)();    /* key comparison function */
27 <        void    (*freek)();     /* free a key */
28 <        void    (*freed)();     /* free the data */
29 <        int     tsiz;           /* current table size */
30 <        LUENT   *tabl;          /* table, if allocated */
31 <        int     ndel;           /* number of deleted entries */
25 >        lut_hashf_t *hashf;     /* key hash function */
26 >        lut_keycmpf_t *keycmp;  /* key comparison function */
27 >        lut_free_t *freek;              /* free a key */
28 >        lut_free_t *freed;              /* free the data */
29 >        int     tsiz;                   /* current table size */
30 >        LUENT   *tabl;                  /* table, if allocated */
31 >        int     ndel;                   /* number of deleted entries */
32   } LUTAB;
33  
25 #define LU_SINIT(fk,fd)         {lu_shash,strcmp,(void (*)())(fk),\
26                                (void (*)())(fd),0,NULL,0}
34  
35   /*
36   * The lu_init routine is called to initialize a table.  The number of
# Line 59 | Line 66 | typedef struct {
66   * It is therefore an error to reuse or do anything with the key
67   * field after calling lu_delete.
68   *
69 + * The lu_doall routine loops through every filled table entry, calling
70 + * the given function once on each entry.  If a NULL pointer is passed
71 + * for this function, then lu_doall simply returns the total number of
72 + * active entries.  Otherwise, it returns the sum of all the function
73 + * evaluations.
74 + *
75   * The lu_done routine calls the given free function once for each
76   * assigned table entry (i.e. each entry with an assigned key value).
77   * The user must define these routines to free the key and the data
# Line 66 | Line 79 | typedef struct {
79   * allocated table itself.
80   */
81  
82 < extern int      lu_init();
70 < extern LUENT    *lu_find();
71 < extern void     lu_delete();
72 < extern void     lu_done();
73 < extern long     lu_shash();
82 > typedef int lut_doallf_t(LUENT *e, void *p);
83  
84 < extern int      strcmp();
84 > extern lut_keycmpf_t lu_strcmp;
85 > extern int      lu_init(LUTAB *tbl, int nel);
86 > extern unsigned long    lu_shash(void *s);
87 > extern LUENT    *lu_find(LUTAB *tbl, char *key);
88 > extern void     lu_delete(LUTAB *tbl, char *key);
89 > extern int      lu_doall(LUTAB *tbl, lut_doallf_t *f, void *p);
90 > extern void     lu_done(LUTAB *tbl);
91 >
92 > #define LU_SINIT(fk,fd) {lu_shash,lu_strcmp,fk,fd,0,NULL,0}
93 >
94 > #ifdef __cplusplus
95 > }
96 > #endif
97 > #endif /* _RAD_LOOKUP_H_ */
98 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines