2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - Département ASIM
4 * Universite Pierre et Marie Curie
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
9 * This progam is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
14 * Alliance VLSI CAD System is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with the GNU C Library; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Tool : ABL, BDD, HT Librarie
28 * Modified by Czo <Olivier.Sirol@lip6.fr> 1996,97
33 #ident "$Id: log_thashloc.c,v 1.4 2005/05/03 08:26:33 antony Exp $"
35 /*--------------------------------------------------------------------------
36 la table de hachage local
37 la version du 14.12.90
38 -------------------------------------------------------------------------- */
45 /* les fonction de l'utilisateurs :
46 ------------------------------
48 initialisation au depart des pointeurs de vertex a NULL.
49 Les fonctions qui utilisent le hachage peuvent renvoye DDBTABLE_PLEINE
50 si la table est trop remplie.
51 Il n'y a pas de destruction possible d'un element.
55 pTableLoc createTabLoc(len)
58 b. destruction de la table
60 void destroyTabLoc(pTab)
63 c. re-allocation d'une table de hachage
68 d. recherche d'un element
70 pNode searchTabLoc(pTab,high,low)
76 int addTabLoc(pTab,pLoc)
80 f. affichage total d'une table
88 /*-------------------- la fonction de hachage ---------------------------- */
94 return (abs (high
->index
+ low
->index
+
95 (((long) high
) >> 4) + (((long) low
) >> 5) +
96 (long) high
+ (long) low
));
99 /*--------------- La table de hachage pour des LOC ------------ */
101 /* la fonction de creation de table de hachage pour les LOC .
102 On alloue en premier lieu une structure TABLE, puis une table
103 qui n'est rien d'autre qu'un tableau de pointeurs de LOC. Il est
104 donc possible de travailler avec plusieurs table a la fois. */
114 if (!(pTab
= (pTableLoc
) mbkalloc (sizeof (struct tableLoc
))))
116 avt_errmsg(LOG_ERRMSG
,"000",AVT_FATAL
,"158");
117 // printf ("allocation impossible\n");
120 pTab
->lenTabLoc
= len
;
122 if (!(pLoc
= (pVertexLoc
) mbkalloc (len
* sizeof (struct vertexLoc
))))
124 avt_errmsg(LOG_ERRMSG
,"000",AVT_FATAL
,"159");
125 // printf ("allocation impossible\n");
129 for (i
= 0; i
< len
; i
++)
131 pLoc
->oper
= EMPTYTH
; /* -1 */
137 /* destruction d'une table de hachage */
143 mbkfree (pTab
->pLoc
);
147 /* recherche d'un element dans la table
148 renvoie NULL si la recherche echoue. */
151 searchTabLoc (pTab
, high
, low
, oper
)
159 /* un seul acces permis */
161 indice
= hashLoc (high
, low
) % pTab
->lenTabLoc
;
163 if (pLoc
[indice
].oper
== oper
)
164 if (high
== pLoc
[indice
].high
&& low
== pLoc
[indice
].low
)
165 return (pLoc
[indice
].father
);
169 /* ajout d'un element a la table */
173 addTabLoc (pTab
, high
, low
, father
, oper
)
175 pNode high
, low
, father
;
181 /* un seul acces permis */
183 indice
= hashLoc (high
, low
) % pTab
->lenTabLoc
;
185 pLoc
[indice
].oper
= oper
;
186 pLoc
[indice
].high
= high
;
187 pLoc
[indice
].low
= low
;
188 pLoc
[indice
].father
= father
;
189 return (indice
); /* retourne la place utilisee */
193 /* affichage des elements de la table */
205 printf ("\n---------------------------------------------------------------");
206 printf ("---------\n AFFICHAGE DE LA TABLE DE HACHAGE\n\n");
208 for (i
= 0; i
< pTab
->lenTabLoc
; i
++)
210 if (pLoc
[i
].oper
!= EMPTYTH
)
213 printf ("****** indice %d ****** \n", i
);
214 printf ("HIGH %ld LOW %ld FATHER %ld\n", (long) pLoc
[i
].high
, (long) pLoc
[i
].low
, (long) pLoc
[i
].father
);
218 printf ("\n****** Nombre de noeuds dans la table = %d\n", co
);
223 /*------------------------------------------------------------------------------
224 videTabLoc :vide une table de hachage locale.
225 -------------------------------------------------------
226 parametres :une table de hashage locale.
227 -------------------------------------------------------
229 ------------------------------------------------------------------------------*/
241 for (i
= 0; i
< pTab
->lenTabLoc
; i
++)
243 pLoc
[i
].oper
= EMPTYTH
;