Azinix

heap.c File Reference

Heap code. More...

#include "heap.h"

Go to the source code of this file.

Functions

Heap_tHeap_InitN (int(*less)(char *, char *), int N)
 Create a heap with N entries.
Heap_tHeap_Init (int(*less)(char *, char *))
 Create a heap with 0 entries.
void Heap_Insert (Heap_t *aHeap, char *entry)
 Insert an entry into a heap.
int Heap_Size (Heap_t *aHeap)
 Returns the number of elements in the heap.
char * Heap_ReadMax (Heap_t *aHeap)
 Return the max element of the heap; does not change heap.
void Heap_Heapify (Heap_t *aHeap)
 Take a heap which satisfies the heap property everywhere but possibly the root, and make it into a heap.
int Heap_Test ()
 Code to test the heap package.


Detailed Description

Heap code.

Array starts at zero, so left and right children are at (2*index + 1) and ( 2 * index + 2 ).

Definition in file heap.c.


Function Documentation

void Heap_Heapify ( Heap_t aHeap  ) 

Take a heap which satisfies the heap property everywhere but possibly the root, and make it into a heap.

Definition at line 159 of file heap.c.

Heap_t* Heap_Init ( int(*)(char *, char *)   ) 

Create a heap with 0 entries.

AutomaticStart

Definition at line 81 of file heap.c.

Heap_t* Heap_InitN ( int(*)(char *, char *)  less,
int  N 
)

Create a heap with N entries.

Definition at line 65 of file heap.c.

void Heap_Insert ( Heap_t aHeap,
char *  entry 
)

Insert an entry into a heap.

Definition at line 92 of file heap.c.

char* Heap_ReadMax ( Heap_t aHeap  ) 

Return the max element of the heap; does not change heap.

Definition at line 142 of file heap.c.

int Heap_Size ( Heap_t aHeap  ) 

Returns the number of elements in the heap.

Definition at line 131 of file heap.c.

int Heap_Test (  ) 

Code to test the heap package.

Definition at line 232 of file heap.c.