GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / dev > encdec / rhel5-64


Interface   Data Structures   File List   Data Fields   Globals  

HEAP.h File Reference

HEAP, interface file. More...


Classes

struct  _HEAP
 Context structure for a heap. More...

Typedefs

typedef int(* HEAP_compare )(const void *key1, const void *key2)
 Comparison function used to sort the heap.
typedef void(* HEAP_destroy )(void *data)
 Call back function to destroy (freed) the data.
typedef struct _HEAP HEAP
 Typedef for struct _HEAP.

Functions

void HEAP_init (HEAP *heap, HEAP_compare compare, HEAP_destroy destroy)
 Initializes a heap for use.
void HEAP_free (HEAP *heap)
 Frees all the nodes of the heap.
int HEAP_insert (HEAP *heap, const void *data)
 Inserts a node with the specified data on the heap.
int HEAP_extract (HEAP *heap, void **data)
 Extracts (removes) the top node of the heap.
static __inline int HEAP__size (HEAP *heap)
 Returns the size of the heap,.


Detailed Description

HEAP, interface file.

Author:
JJRussell - russell@slac.stanford.edu

CVS $Id

Warning:
In their current state, these routines are not fit for Flight use. They can be used in studies. However they malloc all over the place and involve recursive calling techniques, neither of is appropriate for Flight code.

Typedef Documentation

Typedef for struct _HEAP.

This structure is not meant to be directly manipulated by the user. It should be treated as a C++ private member

Comparison function used to sort the heap.

Return values:
<0 if key1 < key2
=0 if key1 = key2
>0 if key1 > key2
Parameters:
key1 Pointer to the first data structure to be sorted
key2 Pointer to the second data structure to be sorted

Call back function to destroy (freed) the data.

Parameters:
data The data to be destroyed (freed)


Function Documentation

HEAP__size ( HEAP heap  )  [static]

Returns the size of the heap,.

Returns:
The size of the heap, i.e. the number of nodes in the heap.
Parameters:
heap The heap to size

References _HEAP::size.

Referenced by HEAP_extract(), HEAP_free(), and HEAP_insert().

int HEAP_extract ( HEAP heap,
void **  data 
)

Extracts (removes) the top node of the heap.

Returns:
Status
Parameters:
heap The heap to remove the node from
data Returned as a pointer to the data associated with the node
The return value is -1 if the heap is empty or an internal error occurs.

References _HEAP::compare, HEAP__size(), _HEAP::size, and _HEAP::tree.

void HEAP_free ( HEAP heap  ) 

Frees all the nodes of the heap.

Parameters:
heap The heap to free

References _HEAP::destroy, HEAP__size(), and _HEAP::tree.

void HEAP_init ( HEAP heap,
HEAP_compare  compare,
HEAP_destroy  destroy 
)

Initializes a heap for use.

Parameters:
heap The heap control structure to initialize
compare Callback comparision routine
destroy Callback destruction (free) routine

References _HEAP::compare, _HEAP::destroy, _HEAP::size, and _HEAP::tree.

int HEAP_insert ( HEAP heap,
const void *  data 
)

Inserts a node with the specified data on the heap.

Returns:
Status
Parameters:
heap The heap to insert the node on
data The data
The only reason for failure is if the heap is specified as NULL

References _HEAP::compare, HEAP__size(), _HEAP::size, and _HEAP::tree.


Generated on Thu Feb 9 12:21:47 2012 by  doxygen 1.5.8