cudd
3.0.0
The University of Colorado Decision Diagram Package
|
Functions for heap-based priority queues. More...
#include "ntr.h"
Data Structures | |
struct | NtrHeapSlot |
Entry of NtrHeap. More... | |
struct | NtrHeap |
Heap-based priority queue. More... | |
Macros | |
#define | PARENT(i) (((i)-1)>>1) |
#define | RIGHT(i) (((i)+1)<<1) |
#define | LEFT(i) (((i)<<1)|1) |
#define | ITEM(p, i) ((p)[i].item) |
#define | KEY(p, i) ((p)[i].key) |
Functions | |
NtrHeap * | Ntr_InitHeap (int size) |
Initializes a priority queue. More... | |
void | Ntr_FreeHeap (NtrHeap *heap) |
Frees a priority queue. More... | |
int | Ntr_HeapInsert (NtrHeap *heap, void *item, int key) |
Inserts an item in a priority queue. More... | |
int | Ntr_HeapExtractMin (NtrHeap *heap, void *item, int *key) |
Extracts the element with the minimum key from a priority queue. More... | |
int | Ntr_HeapCount (NtrHeap *heap) |
Returns the number of items in a priority queue. More... | |
NtrHeap * | Ntr_HeapClone (NtrHeap *source) |
Clones a priority queue. More... | |
void | Ntr_HeapForeach (NtrHeap *heap, void(*f)(void *e, void *arg), void *arg) |
Calls a function on all items in a heap. | |
int | Ntr_TestHeap (NtrHeap *heap, int i) |
Tests the heap property of a priority queue. More... | |
static void | ntrHeapify (NtrHeap *heap, int i) |
Maintains the heap property of a priority queue. More... | |
static int | ntrHeapResize (NtrHeap *heap) |
Resizes a priority queue. More... | |
Functions for heap-based priority queues.
The functions in this file manage a priority queue implemented as a heap. The first element of the heap is the one with the smallest key. The queue stores generic pointers, but the key must be an int. Refer to Chapter 7 of Cormen, Leiserson, and Rivest for the theory.
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.
void Ntr_FreeHeap | ( | NtrHeap * | heap | ) |
int Ntr_HeapCount | ( | NtrHeap * | heap | ) |
Returns the number of items in a priority queue.
int Ntr_HeapExtractMin | ( | NtrHeap * | heap, |
void * | item, | ||
int * | key | ||
) |
Extracts the element with the minimum key from a priority queue.
int Ntr_HeapInsert | ( | NtrHeap * | heap, |
void * | item, | ||
int | key | ||
) |
Inserts an item in a priority queue.
NtrHeap* Ntr_InitHeap | ( | int | size | ) |
Initializes a priority queue.
int Ntr_TestHeap | ( | NtrHeap * | heap, |
int | i | ||
) |
Tests the heap property of a priority queue.
|
static |
|
static |
Resizes a priority queue.
Resizes a priority queue by doubling the number of available slots.