cudd/cuddLevelQ.c File Reference

Procedure to manage level queues. More...

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

Defines

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

Functions

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

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

Copyright (c) 1995-2015, Regents of the University of Colorado

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Define Documentation

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

Hash function for the table of a level queue.

Side effects
None
See also:
hashInsert hashLookup hashDelete

Function Documentation

void cuddLevelQueueDequeue ( DdLevelQueue queue,
int  level 
)

Remove an item from the front of a level queue.

Side effects
None
See also:
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:
queue level queue
key key to be enqueued
level level at which to insert
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:
queue level queue
key key to be enqueued
level level at which to insert
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:
levels number of levels
itemSize size of the item
numBuckets initial number of hash buckets
void cuddLevelQueueQuit ( DdLevelQueue queue  ) 

Shuts down a level queue.

Releases all the associated memory.

Side effects
None
See also:
cuddLevelQueueInit
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
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
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
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
 All Data Structures Files Functions Variables Typedefs Enumerations Defines

Generated on 31 Dec 2015 for cudd by  doxygen 1.6.1