cudd  3.0.0
The University of Colorado Decision Diagram Package
Macros | Functions
cuddLevelQ.c File Reference

Procedure to manage level queues. More...

#include "util.h"
#include "cuddInt.h"
Include dependency graph for cuddLevelQ.c:

Macros

#define lqHash(key, shift)   (((unsigned)(ptruint)(key) * DD_P1) >> (shift))
 Hash function for the table of a level queue. More...
 

Functions

DdLevelQueuecuddLevelQueueInit (int levels, int itemSize, int numBuckets, DdManager *manager)
 Initializes a level queue. More...
 
void cuddLevelQueueQuit (DdLevelQueue *queue)
 Shuts down a level queue. More...
 
void * cuddLevelQueueEnqueue (DdLevelQueue *queue, void *key, int level)
 Inserts a new key in a level queue. More...
 
void * cuddLevelQueueFirst (DdLevelQueue *queue, void *key, int level)
 Inserts the first key in a level queue. More...
 
void cuddLevelQueueDequeue (DdLevelQueue *queue, int level)
 Remove an item from the front of a level queue. More...
 
static DdQueueItemhashLookup (DdLevelQueue *queue, void *key)
 Looks up a key in the hash table of a level queue. More...
 
static int hashInsert (DdLevelQueue *queue, DdQueueItem *item)
 Inserts an item in the hash table of a level queue. More...
 
static void hashDelete (DdLevelQueue *queue, DdQueueItem *item)
 Removes an item from the hash table of a level queue. More...
 
static int hashResize (DdLevelQueue *queue)
 Resizes the hash table of a level queue. More...
 

Detailed Description

Procedure to manage level queues.

The functions in this file allow an application to easily manipulate a queue where nodes are prioritized by level. The emphasis is on efficiency. Therefore, the queue items can have variable size. If the application does not need to attach information to the nodes, it can declare the queue items to be of type DdQueueItem. Otherwise, it can declare them to be of a structure type such that the first three fields are data pointers. The third pointer points to the node. The first two pointers are used by the level queue functions. The remaining fields are initialized to 0 when a new item is created, and are then left to the exclusive use of the application. On the DEC Alphas the three pointers must be 32-bit pointers when CUDD is compiled with 32-bit pointers. The level queue functions make sure that each node appears at most once in the queue. They do so by keeping a hash table where the node is used as key. Queue items are recycled via a free list for efficiency.

Author
Fabio Somenzi

Macro Definition Documentation

◆ lqHash

#define lqHash (   key,
  shift 
)    (((unsigned)(ptruint)(key) * DD_P1) >> (shift))

Hash function for the table of a level queue.

Side effects None
See also
hashInsert hashLookup hashDelete

Function Documentation

◆ cuddLevelQueueDequeue()

void cuddLevelQueueDequeue ( DdLevelQueue queue,
int  level 
)

Remove an item from the front of a level queue.

Side effects None
See also
cuddLevelQueueEnqueue

◆ cuddLevelQueueEnqueue()

void* cuddLevelQueueEnqueue ( DdLevelQueue queue,
void *  key,
int  level 
)

Inserts a new key in a level queue.

A new entry is created in the queue only if the node is not already enqueued.

Returns
a pointer to the queue item if successful; NULL otherwise.
Side effects None
See also
cuddLevelQueueInit cuddLevelQueueDequeue
Parameters
queuelevel queue
keykey to be enqueued
levellevel at which to insert

◆ cuddLevelQueueFirst()

void* cuddLevelQueueFirst ( DdLevelQueue queue,
void *  key,
int  level 
)

Inserts the first key in a level queue.

Returns
a pointer to the queue item if successful; NULL otherwise.
Side effects None
See also
cuddLevelQueueEnqueue
Parameters
queuelevel queue
keykey to be enqueued
levellevel at which to insert

◆ cuddLevelQueueInit()

DdLevelQueue* cuddLevelQueueInit ( int  levels,
int  itemSize,
int  numBuckets,
DdManager manager 
)

Initializes a level queue.

A level queue is a queue where inserts are based on the levels of the nodes. Within each level the policy is FIFO. Level queues are useful in traversing a BDD top-down. Queue items are kept in a free list when dequeued for efficiency.

Returns
a pointer to the new queue if successful; NULL otherwise.
Side effects None
See also
cuddLevelQueueQuit cuddLevelQueueEnqueue cuddLevelQueueDequeue
Parameters
levelsnumber of levels
itemSizesize of the item
numBucketsinitial number of hash buckets

◆ cuddLevelQueueQuit()

void cuddLevelQueueQuit ( DdLevelQueue queue)

Shuts down a level queue.

Releases all the associated memory.

Side effects None
See also
cuddLevelQueueInit

◆ hashDelete()

static void hashDelete ( DdLevelQueue queue,
DdQueueItem item 
)
static

Removes an item from the hash table of a level queue.

Nothing is done if the item is not in the table.

Side effects None
See also
cuddLevelQueueDequeue hashInsert

◆ hashInsert()

static int hashInsert ( DdLevelQueue queue,
DdQueueItem item 
)
static

Inserts an item in the hash table of a level queue.

No check is performed to see if an item with the same key is already in the hash table.

Returns
1 if successful; 0 otherwise.
Side effects None
See also
cuddLevelQueueEnqueue

◆ hashLookup()

static DdQueueItem* hashLookup ( DdLevelQueue queue,
void *  key 
)
static

Looks up a key in the hash table of a level queue.

Returns
a pointer to the item with the given key if the key is found; NULL otherwise.
Side effects None
See also
cuddLevelQueueEnqueue hashInsert

◆ hashResize()

static int hashResize ( DdLevelQueue queue)
static

Resizes the hash table of a level queue.

Returns
1 if successful; 0 otherwise.
Side effects None
See also
hashInsert