Mesh Library - Heap
Structure: | Node |
Source: | heap.c |
Definition:
struct node{
int type;
void * p;
double v;
Node * next;
Node * prev;
};
Data Memeber
- type - indicating the data type of pointer p
- p - universial pointer
- v - value associated with pointer p
- next,prev - pointers in the double linked list. Not used in current version.
Methods
- int NodeCompare(Node *a, Node *b);
compare two node. You can change this for your purpose.
- void heapsort(Node * a[],int N);
Heap sort. a[] is array of nodes, N is the dimension of the array.
- Node * heapSelectMin();
Return the minimum in the heap
- Node * heapNode( void * v);
Given universial pointer v, find the node in the heap which contains v
- void heapUpheap( void * v);
Updating heap.When a node value in the heap is changed, the new value is
less than old value, then move this node up in the heap.
- void heapDownheap( void * v);
Updating heap.When a node value in the heap is changed, the new value is
greater than old value, then move this node down in the heap.
- void heapCheck();
Check the consistency of the heap.