- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Containers::DynamicHeap Class Reference

`#include <DynamicHeap.h>`

Inheritance diagram for Mers::Utils::Containers::DynamicHeap:

[legend]
Collaboration diagram for Mers::Utils::Containers::DynamicHeap:

[legend]
List of all members.

## Public Member Functions
| DynamicHeap (bool myLargestFirstHeap, DynamicArray::DynamicArrayType myHeapType, bool myOwnershipStatus)
virtual | ~DynamicHeap ()
## Protected Member Functions
| DynamicHeap (DynamicHeap const &other)
| DynamicHeap (DynamicHeap const *other)
void | heapify (unsigned int elementIndex)
int | insert (void *element)
int | peekFirst (void *&element)
int | getFirst (void *&element)
virtual bool | greaterThan (void const *e1, void const *e2) const=0
virtual bool | lessThan (void const *e1, void const *e2) const=0
## Protected Attributes
bool | largestFirst

## Detailed Description

A dynamic heap that can be least first or greatest first. As with DynamicArray, this is supposed to be inherited and used by a task-specific class.

Author:
  Paul H. Elliott

Definition at line 34 of file DynamicHeap.h.

## Constructor & Destructor Documentation

DynamicHeap::DynamicHeap | ( | bool | myLargestFirstHeap,
|  | DynamicArray::DynamicArrayType | myHeapType,
|  | bool | myOwnershipStatus |
| ) |  |  |

Creates a new, empty heap.

Parameters:

  | myLargestFirstHeap | set this to true to have the top element be the largest element in the heap, set it to false to have it be the smallest element in the heap
  | myHeapType | the object type of this dynamic array.
  | myOwnershipStatus | the ownership status. If true, this object owns the array objects it contains and should delete them upon being deleted.

Definition at line 23 of file DynamicHeap.cpp.

References largestFirst.

DynamicHeap::~DynamicHeap | ( |  | ) | `[virtual]`

Destroys the heap

Definition at line 32 of file DynamicHeap.cpp.

DynamicHeap::DynamicHeap | ( | DynamicHeap const & | other | ) | `[protected]`

Creates a new heap with a copy of the contents from the other heap. This can be an expensive operation.

Parameters:

  | other | the heap whos contents are copied

Definition at line 39 of file DynamicHeap.cpp.

References largestFirst.

DynamicHeap::DynamicHeap | ( | DynamicHeap const * | other | ) | `[protected]`

Creates a new heap with a copy of the contents from the other heap. This can be an expensive operation.

Parameters:

  | other | the heap whos contents are copied

Definition at line 47 of file DynamicHeap.cpp.

References largestFirst.

## Member Function Documentation

void DynamicHeap::heapify | ( | unsigned int | elementIndex | ) | `[protected]`

Floats the value at elementIndex down into the heap so the subtree rooted at elementIndex is a heap. Note that this assumes only elementIndex is out of place.

Parameters:

  | elementIndex | the index of the subtree being heapified

Definition at line 55 of file DynamicHeap.cpp.

References Mers::Utils::Containers::DynamicArray::array, greaterThan(), largestFirst, lessThan(), and Mers::Utils::Containers::DynamicArray::mSize.

Referenced by getFirst().

Here is the call graph for this function:

int DynamicHeap::insert | ( | void * | element | ) | `[protected]`

Inserts a new element into the heap. This object assumes ownership of the element.

Parameters:

  | element | the new element being inserted in the heap

Returns:
  0 on success or a positive number if there was insufficient room

Definition at line 83 of file DynamicHeap.cpp.

References Mers::Utils::Containers::DynamicArray::array, Mers::Utils::Containers::DynamicArray::dynamicArrayTypeToString(), Mers::Utils::Containers::DynamicArray::getDynamicArrayType(), greaterThan(), largestFirst, lessThan(), Mers::Utils::Containers::DynamicArray::mSize, and Mers::Utils::Containers::DynamicArray::pushBack().

Here is the call graph for this function:

int DynamicHeap::peekFirst | ( | void *& | element | ) | `[protected]`

Returns the first (largest/smallest) element in the heap, if any but leaves it on the heap.

Parameters:

  | element | the first element is returned here

Returns:
  0 on success or a positive number if the heap was empty, this also sets element to NULL.

Definition at line 112 of file DynamicHeap.cpp.

References Mers::Utils::Containers::DynamicArray::array, and Mers::Utils::Containers::DynamicArray::mSize.

int DynamicHeap::getFirst | ( | void *& | element | ) | `[protected]`

Returns the first (largest/smallest) element in the heap and then removes it from the heap. This object relinquishes control of element.

Parameters:

  | element | the first element is returned here

Returns:
  0 on success or a positive number if the heap was empty, this also sets element to NULL

Definition at line 126 of file DynamicHeap.cpp.

References Mers::Utils::Containers::DynamicArray::array, heapify(), Mers::Utils::Containers::DynamicArray::mSize, and Mers::Utils::Containers::DynamicArray::popBack().

Here is the call graph for this function:

virtual bool Mers::Utils::Containers::DynamicHeap::greaterThan | ( | void const * | e1,
|  | void const * | e2 |
| ) |  |  | const`[protected, pure virtual]`

Returns true if the first element is larger than the second element derived classes should define this for the contents of the heap.

Parameters:

  | e1 | the first element being compared to the second element
  | e2 | the second element being compared

Returns:
  valueOf(e1) > valueOf(e2)

Implemented in Mers::Estimation::Discrete::EstimateHeap, and Mers::Generators::BFIG::BFIGImplicantHeap.

Referenced by heapify(), and insert().

virtual bool Mers::Utils::Containers::DynamicHeap::lessThan | ( | void const * | e1,
|  | void const * | e2 |
| ) |  |  | const`[protected, pure virtual]`

Returns true if the first element is smaller than the second element derived classes should define this for the contents of the heap.

Parameters:

  | e1 | the first element being compared to the second element
  | e2 | the second element being compared

Returns:
  valueOf(e1) < valueOf(e2)

Implemented in Mers::Estimation::Discrete::EstimateHeap, and Mers::Generators::BFIG::BFIGImplicantHeap.

Referenced by heapify(), and insert().

## Member Data Documentation

bool Mers::Utils::Containers::DynamicHeap::largestFirst`[protected]`

true if we're using the greaterThan procedure, false if we're using the lessThan procedure.

Definition at line 159 of file DynamicHeap.h.

Referenced by DynamicHeap(), heapify(), and insert().

The documentation for this class was generated from the following files:

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/DynamicHeap.h
- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/DynamicHeap.cpp