box_heap.h File Reference

Detailed Description

This is a collection of functions working on box heaps. A box heap is a special heap including boxes. This specialization is handy since it facilitates the manipulation of sorted sets of boxes.

See Also
heap.h, box.h, Theap, Tbox.

Definition in file box_heap.h.

Macros

#define INIT_NUM_BOXES_IN_HEAP   100
 Initial room for boxes in a heap of boxes. More...
 

Functions

void InitHeapOfBoxes (boolean(*LessThan)(void *, void *, void *), void *userData, Theap *h)
 Constructor. More...
 
void AddBox2HeapOfBoxes (Tbox *b, Theap *h)
 Adds a box to a heap of boxes. More...
 
double HeapOfBoxesVolume (boolean *used, Theap *h)
 Computes the volume of a heap. More...
 
double HeapOfBoxesMaxDiagonal (boolean *used, Theap *h)
 Computes the maximum diagonal for all boxes in a heap. More...
 
double HeapOfBoxesMaxSize (boolean *used, Theap *h)
 Computes the maximum size for all boxes in a heap. More...
 
void Heap2List (Tlist *l, Theap *h)
 Converts a heap of boxes into a list. More...
 
void AddList2Heap (Tlist *l, Theap *h)
 Adds a list of boxes into a heap. More...
 
void PrintHeapOfBoxes (FILE *f, boolean *used, char *heading, Theap *h)
 Prints a heap of boxes. More...
 

Macro Definition Documentation

#define INIT_NUM_BOXES_IN_HEAP   100

Initial room for boxes in a heap. It will be enlarged if necessary.

See Also
InitHeap

Definition at line 27 of file box_heap.h.

Referenced by InitHeapOfBoxes().

Function Documentation

void InitHeapOfBoxes ( boolean(*)(void *, void *, void *)  LessThan,
void *  userData,
Theap h 
)

Defines an empty heap of boxes.

Parameters
LessThanThe function defining the sorting criterion for the boxes in the heap.
userDataThe pointer to the data to pass to the LessThan operator as a third parameter.
hThe heap to create.
See Also
CmpBoxDepthFirst, CmpBoxBreadthFirst, InitHeap.

Definition at line 21 of file box_heap.c.

References CopyBox(), DeleteBox(), FALSE, INIT_NUM_BOXES_IN_HEAP, and InitHeap().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

void AddBox2HeapOfBoxes ( Tbox b,
Theap h 
)

Adds a box to a heap of boxes. The box is copied into the heap and, thus, it can be freely modified after calling this function.

Parameters
bThe box to add.
hThe heap where to add the box.

Definition at line 26 of file box_heap.c.

References AddElement2Heap(), and NO_UINT.

Referenced by MPI_SolveCuikSystem(), PostProcessBox(), and SolveCuikSystem().

double HeapOfBoxesVolume ( boolean used,
Theap h 
)

Computes the sum of the volume of the boxes stored in the heap.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
hThe heap.
See Also
BoxVolume

Definition at line 31 of file box_heap.c.

References GetBoxVolume(), GetHeapElement(), and HeapSize().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

double HeapOfBoxesMaxDiagonal ( boolean used,
Theap h 
)

Computes the maximum diagonal for all the boxes stored in the heap.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
hThe heap.
See Also
BoxDiagonal

Definition at line 45 of file box_heap.c.

References GetBoxDiagonal(), GetHeapElement(), and HeapSize().

double HeapOfBoxesMaxSize ( boolean used,
Theap h 
)

Computes the maximum size for all the boxes stored in the heap.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
hThe heap.
See Also
BoxSize

Definition at line 63 of file box_heap.c.

References GetBoxSize(), GetHeapElement(), and HeapSize().

void Heap2List ( Tlist l,
Theap h 
)

Converts a heap of boxes into a list of boxes. The list is constructed (i.e., initialized) inside the function.

Parameters
lThe list to defined.
hThe heap to convert into a list.
See Also
box_list.h

Definition at line 82 of file box_heap.c.

References AddLastElement(), CopyBox(), GetHeapElement(), HeapSize(), and InitListOfBoxes().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

void AddList2Heap ( Tlist l,
Theap h 
)

Adds a list of boxes into a previously initialized heap.

Parameters
lThe list with the boxes to add to the heap.
hThe heap where to add the boxes.
See Also
box_list.h

Definition at line 97 of file box_heap.c.

References AddElement2Heap(), Advance(), EndOfList(), First(), GetCurrent(), InitIterator(), and NO_UINT.

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

void PrintHeapOfBoxes ( FILE *  f,
boolean used,
char *  heading,
Theap h 
)

Prints a heap of boxes to a stream that can be stdout.

The elements of the heap are printed breadth first.

Parameters
fThe stream where to write.
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
headingA string to be printed before each box. Possibly NULL, in which case nothing is printed. This is used to differentiate heap printed in the same file.
hThe heap to be printed.
See Also
PrintBox

Definition at line 110 of file box_heap.c.

References GetHeapElement(), HeapSize(), and PrintBoxSubset().