Menu

[6b5286]: / hash.h  Maximize  Restore  History

Download this file

45 lines (38 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* $Id: hash.h,v 1.3 2007/03/20 09:40:54 mihajlov Exp $
*
* (C) Copyright IBM Corp. 2004
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
* CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
*
* You can obtain a current copy of the Eclipse Public License from
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* Author: Viktor Mihajlovski <mihajlov@de.ibm.com>
* Contributors:
*
* Description: Hashtable for Parser Symbol Tables.
*
*/
#if !defined HASHH
#define HASHH
# define RADIX 17
# define MAXHASH (( 1 << RADIX ) - 1) /* 2^RADIX-1 elements in hash table */
typedef struct{
char * he_key;
enum { HE_FREE, HE_USED } he_state;
union {
void * ptr; /* for regular entry */
int number; /* for table head */
} he;
} hashentry;
hashentry * htcreate( const char * );
void htdelete( hashentry * );
void * htlookup( hashentry *, const char *, unsigned );
int htinsert( hashentry *, const char *, unsigned, void * );
unsigned fold(const char *, unsigned);/* folds string into machine word */
unsigned primary( unsigned ); /* returns primary hash index */
unsigned secondary( unsigned ); /* returns secondary hash index */
#endif /* HASHH */
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.