~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to incl/hash.h

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)hash.h   19.1 (ESO-IPG) 02/25/03 13:49:34 */
 
2
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
3
.TYPE           Header
 
4
.NAME           hash.h
 
5
.VERSION 1.0    18-Apr-1988: Creation
 
6
.LANGUAGE       C
 
7
.AUTHOR         Francois Ochsenbein [ESO-IPG]
 
8
.CATEGORY       General Hash-Table Definition
 
9
.COMMENTS       A hash table is described by a header.
 
10
.ENVIRONMENT    Any
 
11
------------------------------------------------------------*/
 
12
 
 
13
#ifndef HASH_DEF
 
14
#define HASH_DEF        0
 
15
 
 
16
#ifndef _TEMPLATES_
 
17
#include <compiler.h>
 
18
#endif
 
19
 
 
20
/*===========================================================================
 
21
 *             Structures
 
22
 *===========================================================================*/
 
23
 
 
24
typedef struct s_h_item{
 
25
        struct s_h_item *next;          /* Next definition in chain     */
 
26
        int leq;                        /* Length of Equivalence string */
 
27
        unsigned char ls;               /* Length of symbol             */
 
28
        char strings[2];                /* Strings terminated with EOS  */
 
29
        } H_ITEM;
 
30
 
 
31
typedef struct {
 
32
        int size;                       /* Number of items in table     */
 
33
        int symbols;                    /* Number of symbols            */
 
34
        int collisions;                 /* Number of collisions         */
 
35
        H_ITEM *start[1];               /* Starting points of chains    */
 
36
        } H_TABLE;
 
37
 
 
38
#if _TEMPLATES_
 
39
/*===========================================================================
 
40
 *             Related functions and macros
 
41
 *===========================================================================*/
 
42
int      h_factor       (int n);        /* Hash factor (2 is default)   */
 
43
H_TABLE *h_create       (int size);     /* Size is adjusted to prime    */
 
44
int      h_clear        (H_TABLE *ht);  /* Make table empty             */
 
45
int      h_log          (H_TABLE *ht);  /* Log the table contents       */
 
46
H_ITEM  *h_look         (H_TABLE *ht, char *symbol, int len);
 
47
H_ITEM  *h_add          (H_TABLE *ht, char *symbol, int ls, char *eq, int leq);
 
48
int      h_remove       (H_TABLE *ht, char *symbol, int len);
 
49
char    *h_get          (H_TABLE *ht, char *symbol, int len);
 
50
 
 
51
#else
 
52
H_TABLE *h_create();
 
53
H_ITEM  *h_add(), *h_look();    
 
54
char    *h_get();
 
55
#endif
 
56
 
 
57
#define H_Create(size)          h_create(size)
 
58
#define H_Clear(ht)             h_clear(ht)
 
59
#define H_Lookup(ht,s)          h_look(ht,s,strlen(s))
 
60
#define H_Gets(ht,s)            h_get(ht,s,strlen(s))
 
61
#define H_Add(ht,s,eq)          h_add(ht,s,strlen(s),eq,strlen(eq))
 
62
#define H_Remove(ht,s)          h_remove(ht,s,strlen(s))
 
63
 
 
64
#endif