1SETHTITEM(3)          MBK HASH TABLE MANAGEMENT FUNCTIONS         SETHTITEM(3)
2
3
4

NAME

6       sethtitem - test and set an item in an hash table.
7

SYNOPSIS

9       #include "mut.h"
10       int sethtitem(table, key)
11       ht ∗table;
12       void ∗key;
13

PARAMETERS

15       table               Hash table pointer
16
17       key                 Key used by the hash coding function to set an item
18

DESCRIPTION

20       sethtitem() adds an item in the hash table pointed to by table, whether
21       it existed or not, and returns an appropriate value.  This is kind of a
22       test and set operator.
23

RETURN VALUE

25       If  the  key  exists, the function return 1, if it doesn't, the item is
26       stored and the function returns 0.
27

EXAMPLE

29       #include <stdio.h>
30       #include "mut.h"
31       checksigname(p)
32       lofig_list *p;
33       {
34       int i;
35       losig_list *ptsig;
36       locon_list *ptcon;
37       ht *h;
38       char *amatla;
39          for (i = 0, ptsig = p->LOSIG; ptsig; i++, ptsig = ptsig->NEXT);
40          h = addht(i << 1); /* half empty hash tables are faster! */
41          for (ptcon = p->LOCON; ptcon; ptcon = ptcon->NEXT)
42             addhtitem(h, ptcon->NAME, 0);
43          for (ptsig = p->LOSIG; ptsig; ptsig = ptsig->NEXT) {
44             if (ptsig->TYPE == INTERNAL) {
45                amatla = getsigname(ptsig);
46                if (!sethtitem(h, amatla, 0))
47                   printf("node %s is now unique\n", amatla);
48             }
49          }
50          delht(h);
51       }
52

ERRORS

54       "∗∗∗ mbk error ∗∗∗ sethtitem impossible : value is EMPTYHT or DELETEHT"
55              The values EMPTYHT, -1,  and  DELETEHT,  -2,  are  reserved  for
56              internal use, sorry.
57

DIAGNOSTICS

59       The value must be distinct from -1 and -2.
60

SEE ALSO

62       mbk(1),  addht(3),  delht(3), addhtitem(3), gethtitem(3), delhtitem(3),
63       viewht(3).
64
65
66
67
68
69
70ASIM/LIP6                       October 1, 1997                   SETHTITEM(3)
Impressum