Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

heap.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include "l_alloc_new.h"
#include "heap.h"

Go to the source code of this file.

Defines

#define Heap_NodeSwap(a, b)

Functions

void HeapifyMax (Heap *root)
void HeapifyMin (Heap *root)
HeapHeap_Create (int dir)
HeapHeap_Dispose (Heap *root, void(*element_dispose)(void *))
void Heap_Insert (Heap *root, void *element, double weight)
void * Heap_Top (Heap *root)
double * Heap_TopWeight (Heap *root)
void * Heap_ExtractTop (Heap *root)

Variables

char copyright []
L_Alloc_PoolheapNodePool = NULL


Define Documentation

#define Heap_NodeSwap a,
 ) 
 

Value:

{  HeapNode node; \
                                   node.weight = (a)->weight; \
                                   node.element = (a)->element; \
                                   (a)->weight = (b)->weight; \
                                   (a)->element = (b)->element; \
                                   (b)->weight = node.weight; \
                                   (b)->element = node.element; \
                                }

Definition at line 47 of file heap.c.

Referenced by Heap_Insert(), HeapifyMax(), and HeapifyMin().


Function Documentation

Heap* Heap_Create int  dir  ) 
 

Definition at line 120 of file heap.c.

References Heap::dir, Heap::heap, heapNodePool, L_create_alloc_pool(), malloc(), and Heap::size.

Heap* Heap_Dispose Heap root,
void(*  element_dispose)(void *)
 

Definition at line 140 of file heap.c.

References h_node::element, free(), Heap::heap, heapNodePool, L_free(), h_node::left, h_node::p, and h_node::right.

void* Heap_ExtractTop Heap root  ) 
 

Definition at line 252 of file heap.c.

References Heap::dir, h_node::element, Heap::heap, HEAP_MAX, HeapifyMax(), HeapifyMin(), heapNodePool, L_free(), h_node::left, h_node::p, h_node::right, Heap::size, size, and h_node::weight.

void Heap_Insert Heap root,
void *  element,
double  weight
 

Definition at line 173 of file heap.c.

References Heap::dir, h_node::element, Heap::heap, HEAP_MAX, Heap_NodeSwap, heapNodePool, L_alloc(), h_node::left, h_node::p, h_node::right, Heap::size, size, and h_node::weight.

void* Heap_Top Heap root  ) 
 

Definition at line 230 of file heap.c.

References h_node::element, Heap::heap, and Heap::size.

double* Heap_TopWeight Heap root  ) 
 

Definition at line 241 of file heap.c.

References Heap::heap, Heap::size, and h_node::weight.

void HeapifyMax Heap root  )  [static]
 

Definition at line 57 of file heap.c.

References Heap::heap, Heap_NodeSwap, h_node::left, h_node::right, and h_node::weight.

Referenced by Heap_ExtractTop().

void HeapifyMin Heap root  )  [static]
 

Definition at line 87 of file heap.c.

References Heap::heap, Heap_NodeSwap, h_node::left, h_node::right, and h_node::weight.

Referenced by Heap_ExtractTop().


Variable Documentation

char copyright[] [static]
 

Initial value:

"Copyright (c) 1991 Richard Hank, Wen-mei Hwu and The Board of \n\
 Trustees of the University of Illinois. All rights reserved.\n"

Definition at line 16 of file heap.c.

L_Alloc_Pool* heapNodePool = NULL [static]
 

Definition at line 27 of file heap.c.

Referenced by Heap_Create(), Heap_Dispose(), Heap_ExtractTop(), and Heap_Insert().


Generated on Mon Jul 21 20:29:42 2003 for TINKER LEGO DOC by doxygen 1.3.2