Tesseract 3.01
/data/source/tesseract-ocr/cutil/oldheap.h File Reference
#include "host.h"
#include "cutil.h"

Go to the source code of this file.

Classes

struct  HEAPENTRY
struct  HEAP

Defines

#define HEAPFULL   3000
#define EMPTY   -1
#define TESS_HEAP_OK   0
#define FreeHeap(H)   memfree(H)
#define MaxSizeOfHeap(H)   (H->Size)
#define SizeOfHeap(H)   (H->FirstFree - 1)
#define InitHeap(H)   (H->FirstFree = 1)
#define HeapFull(H)   ((H)->FirstFree > (H)->Size)
#define HeapEmpty(H)   ((H)->FirstFree <= 1)
#define HeapKeyFor(H, E)   ((H)->Entry[(E)+1].Key)
#define HeapDataFor(H, E)   ((H)->Entry[(E)+1].Data)

Functions

HEAPMakeHeap (int Size)
int HeapPop (HEAP *Heap, FLOAT32 *Key, void *out_ptr)
int HeapPopWorst (HEAP *Heap, FLOAT32 *Key, void *out_ptr)
void HeapPush (HEAP *Heap, FLOAT32 Key, void *Data)
void HeapStore (HEAP *Heap, HEAPENTRY *Entry)
int GetTopOfHeap (HEAP *Heap, HEAPENTRY *Entry)
void FreeHeapData (HEAP *Heap, void_dest destructor)
bool HeapPushCheckSize (HEAP *Heap, FLOAT32 Key, void *Data)

Define Documentation

#define EMPTY   -1
#define FreeHeap (   H)    memfree(H)
#define HeapDataFor (   H,
 
)    ((H)->Entry[(E)+1].Data)
#define HeapEmpty (   H)    ((H)->FirstFree <= 1)
#define HEAPFULL   3000
#define HeapFull (   H)    ((H)->FirstFree > (H)->Size)
#define HeapKeyFor (   H,
 
)    ((H)->Entry[(E)+1].Key)
#define InitHeap (   H)    (H->FirstFree = 1)
#define MaxSizeOfHeap (   H)    (H->Size)
#define SizeOfHeap (   H)    (H->FirstFree - 1)
#define TESS_HEAP_OK   0

Function Documentation

void FreeHeapData ( HEAP Heap,
void_dest  destructor 
)

This routine is similar to FreeHeap in that it deallocates the memory consumed by the heap. However, it also calls Deallocator for each item in the heap so that this data is also deallocated.

Parameters:
Heapheap whose data is to be freed
Deallocatorfunction to be used to deallocate data

Globals:

  • None
Note:
Exceptions: none
History: Tue May 15 08:52:04 1990, DSJ, Created.
int GetTopOfHeap ( HEAP Heap,
HEAPENTRY Entry 
)

This routine removes the top item on the heap and copies its contents into Entry.

Parameters:
Heapptr to heap whose top is to be removed and returned
Entryptr to heap entry to be filled with top entry on Heap

Globals:

  • None
Returns:
OK if top entry returned, EMPTY if heap is empty
Note:
Exceptions: None
History: 3/13/89, DSJ, Created.
int HeapPop ( HEAP Heap,
FLOAT32 Key,
void *  out_ptr 
)

This routine removes the top item on the heap and places its contents into Key and Data.

Globals:

  • None
Parameters:
Heapptr to heap whose top is to be removed and returned
Keyplace to put key of top heap item
Dataplace to put data of top heap item
Returns:
OK if top entry returned, EMPTY if heap is empty
Note:
Exceptions: None
History: 5/10/91, DSJ, Created (Modified from GetTopOfHeap).
int HeapPopWorst ( HEAP Heap,
FLOAT32 Key,
void *  out_ptr 
)

HeapPopWorst

Remove the largest item from the heap.

Parameters:
Heapptr to heap whose top is to be removed and returned
Keyplace to put key of top heap item
Dataplace to put data of top heap item
void HeapPush ( HEAP Heap,
FLOAT32  Key,
void *  Data 
)

This routine stores Data into Heap and associates it with Key. The heap is maintained in such a way that the item with the lowest key is always at the top of the heap.

Globals:

  • None
Parameters:
Heapptr to heap to store new item in
Keynumeric key associated with new item
Dataptr to data contents of new item
Note:
Exceptions:
  • HEAPFULL error if heap size is exceeded
History: 5/10/91, DSJ, Created (Modified version of HeapStore).
bool HeapPushCheckSize ( HEAP Heap,
FLOAT32  Key,
void *  Data 
)
void HeapStore ( HEAP Heap,
HEAPENTRY Entry 
)

This routine stores Entry into Heap. The heap is maintained in such a way that the item with the lowest key is always at the top of the heap.

Globals:

  • None
Parameters:
Heapptr to heap to store new item in
Entryptr to item to be stored in Heap
Note:
Exceptions:
  • HEAPFULL error if heap size is exceeded
History: 3/13/89, DSJ, Created.
HEAP* MakeHeap ( int  Size)

This routine creates and initializes a new heap data structure containing Size elements. In actuality, Size + 1 elements are allocated. The first element, element 0, is unused, this makes the index arithmetic easier.

Globals:

  • None
Parameters:
Sizemaximum number of entries in the heap
Returns:
Pointer to the new heap.
Note:
Exceptions: None
History: 3/13/89, DSJ, Created.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines