src/cmuBdd/bddhash.c File Reference

#include "bddint.h"
Include dependency graph for bddhash.c:

Go to the source code of this file.

Defines

#define HASH(d)   ((INT_PTR)(d))

Functions

static void bdd_rehash_hash_table (hash_table h)
void bdd_insert_in_hash_table (hash_table h, bdd f, pointer data)
pointer bdd_lookup_in_hash_table (hash_table h, bdd f)
hash_table bdd_new_hash_table (cmu_bdd_manager bddm, int item_size)
void cmu_bdd_free_hash_table (hash_table h)

Define Documentation

#define HASH (  )     ((INT_PTR)(d))

Definition at line 7 of file bddhash.c.


Function Documentation

void bdd_insert_in_hash_table ( hash_table  h,
bdd  f,
pointer  data 
)

Definition at line 47 of file bddhash.c.

00048 {
00049   long hash;
00050   hash_rec p;
00051 
00052   p=(hash_rec)BDD_NEW_REC(h->bddm, ALIGN(sizeof(struct hash_rec_))+h->item_size);
00053   p->key=f;
00054   mem_copy((pointer)(ALIGN(sizeof(struct hash_rec_))+(INT_PTR)p), data, (SIZE_T)h->item_size);
00055   hash=HASH(f);
00056   BDD_REDUCE(hash, h->size);
00057   p->next=h->table[hash];
00058   h->table[hash]=p;
00059   h->entries++;
00060   if ((h->size << 2) < h->entries)
00061     bdd_rehash_hash_table(h);
00062 }

pointer bdd_lookup_in_hash_table ( hash_table  h,
bdd  f 
)

Definition at line 69 of file bddhash.c.

00070 {
00071   long hash;
00072   hash_rec p;
00073 
00074   hash=HASH(f);
00075   BDD_REDUCE(hash, h->size);
00076   for (p=h->table[hash]; p; p=p->next)
00077     if (p->key == f)
00078       return ((pointer)(ALIGN(sizeof(struct hash_rec_))+(char *)p));
00079   return ((pointer)0);
00080 }

hash_table bdd_new_hash_table ( cmu_bdd_manager  bddm,
int  item_size 
)

Definition at line 87 of file bddhash.c.

00088 {
00089   long i;
00090   hash_table h;
00091 
00092   h=(hash_table)BDD_NEW_REC(bddm, sizeof(struct hash_table_));
00093   h->size_index=10;
00094   h->size=TABLE_SIZE(h->size_index);
00095   h->table=(hash_rec *)mem_get_block((SIZE_T)(h->size*sizeof(hash_rec)));
00096   for (i=0; i < h->size; ++i)
00097     h->table[i]=0;
00098   h->entries=0;
00099   h->item_size=item_size;
00100   h->bddm=bddm;
00101   return (h);
00102 }

static void bdd_rehash_hash_table ( hash_table  h  )  [static]

Definition at line 15 of file bddhash.c.

00016 {
00017   long i;
00018   long hash;
00019   long oldsize;
00020   hash_rec *newtable;
00021   hash_rec p, q;
00022 
00023   oldsize=h->size;
00024   h->size_index++;
00025   h->size=TABLE_SIZE(h->size_index);
00026   newtable=(hash_rec *)mem_get_block((SIZE_T)(h->size*sizeof(hash_rec)));
00027   for (i=0; i < h->size; ++i)
00028     newtable[i]=0;
00029   for (i=0; i < oldsize; ++i)
00030     for (p=h->table[i]; p; p=q)
00031       {
00032         q=p->next;
00033         hash=HASH(p->key);
00034         BDD_REDUCE(hash, h->size);
00035         p->next=newtable[hash];
00036         newtable[hash]=p;
00037       }
00038   mem_free_block((pointer)h->table);
00039   h->table=newtable;
00040 }

void cmu_bdd_free_hash_table ( hash_table  h  ) 

Definition at line 108 of file bddhash.c.

00109 {
00110   long i;
00111   hash_rec p, q;
00112 
00113   for (i=0; i < h->size; ++i)
00114     for (p=h->table[i]; p; p=q)
00115       {
00116         q=p->next;
00117         BDD_FREE_REC(h->bddm, (pointer)p, ALIGN(sizeof(struct hash_rec_))+h->item_size);
00118       }
00119   mem_free_block((pointer)h->table);
00120   BDD_FREE_REC(h->bddm, (pointer)h, sizeof(struct hash_table_));
00121 }


Generated on Tue Jan 12 13:57:14 2010 for glu-2.2 by  doxygen 1.6.1