abc/src/bdd/cudd/cuddLCache.c
/**Function********************************************************************

  Synopsis    [Looks up a key consisting of three pointers in a hash table.]

  Description [Looks up a key consisting of three pointers in a hash table.
  Returns the value associated to the key if there is an entry for the given
  key in the table; NULL otherwise. If the entry is present, its reference
  counter is decremented if not saturated. If the counter reaches 0, the
  value of the entry is dereferenced, and the entry is returned to the free
  list.]

  SideEffects [None]

  SeeAlso     [cuddHashTableLookup cuddHashTableLookup1 cuddHashTableLookup2
  cuddHashTableInsert3]

******************************************************************************/
Function
Synopsis    [Looks up a key consisting of three pointers in a hash table.]

Description [Looks up a key consisting of three pointers in a hash table.
Returns the value associated to the key if there is an entry for the given
key in the table; NULL otherwise. If the entry is present, its reference
counter is decremented if not saturated. If the counter reaches 0, the
value of the entry is dereferenced, and the entry is returned to the free
list.]




Function Synopsis [ Looks up a key consisting of three pointers in a hash table . ] Description [ Looks up a key consisting of three pointers in a hash table . Returns the value associated to the key if there is an entry for the given key in the table ; NULL otherwise . If the entry is present its reference counter is decremented if not saturated . If the counter reaches 0 the value of the entry is dereferenced and the entry is returned to the free list . ]
DdNode *
cuddHashTableLookup3(
  DdHashTable * hash,
  DdNode * f,
  DdNode * g,
  DdNode * h)
{
    unsigned int posn;
    DdHashItem *item, *prev;
#ifdef DD_DEBUG
    assert(hash->keysize == 3);
#endif
    posn = ddLCHash3(cuddF2L(f),cuddF2L(g),cuddF2L(h),hash->shift);
    item = hash->bucket[posn];
    prev = NULL;
    while (item != NULL) {
        DdNodePtr *key = item->key;
        if ((f == key[0]) && (g == key[1]) && (h == key[2])) {
            DdNode *value = item->value;
            cuddSatDec(item->count);
            if (item->count == 0) {
                cuddDeref(value);
                if (prev == NULL) {
                    hash->bucket[posn] = item->next;
                } else {
                    prev->next = item->next;
                }
                item->next = hash->nextFree;
                hash->nextFree = item;
                hash->size--;
            }
            return(value);
        }
        prev = item;
        item = item->next;
    }
    return(NULL);
}
DdNode * cuddHashTableLookup3 ( DdHashTable * hash , DdNode * f , DdNode * g , DdNode * h ) { unsigned int posn ; DdHashItem * item , * prev ; #ifdef DD_DEBUG assert ( hash -> keysize == 3 ) ; #endif posn = ddLCHash3 ( cuddF2L ( f ) , cuddF2L ( g ) , cuddF2L ( h ) , hash -> shift ) ; item = hash -> bucket [ posn ] ; prev = NULL ; while ( item != NULL ) { DdNodePtr * key = item -> key ; if ( ( f == key [ 0 ] ) && ( g == key [ 1 ] ) && ( h == key [ 2 ] ) ) { DdNode * value = item -> value ; cuddSatDec ( item -> count ) ; if ( item -> count == 0 ) { cuddDeref ( value ) ; if ( prev == NULL ) { hash -> bucket [ posn ] = item -> next ; } else { prev -> next = item -> next ; } item -> next = hash -> nextFree ; hash -> nextFree = item ; hash -> size -- ; } return ( value ) ; } prev = item ; item = item -> next ; } return ( NULL ) ; }
Function
Synopsis    [Looks up a key consisting of three pointers in a hash table.]
Function Synopsis [ Looks up a key consisting of three pointers in a hash table . ]