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

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

# Mers::Estimation::Discrete::EstimateHeap Class Reference

`#include <EstimateHeap.h>`

Inheritance diagram for Mers::Estimation::Discrete::EstimateHeap:

[legend]
Collaboration diagram for Mers::Estimation::Discrete::EstimateHeap:

[legend]
List of all members.

## Public Member Functions
| EstimateHeap (bool myLargestFirstHeap)
| EstimateHeap (EstimateHeap const &other)
| EstimateHeap (EstimateHeap const *other)
virtual | ~EstimateHeap ()
int | insert (Estimate *element)
int | peekFirst (Estimate *&element)
int | getFirst (Estimate *&element)
void | printElement (std::ostream &out, void const *element) const
## Protected Member Functions
void | deleteElement (void *element) const
void * | newElement (void const *element) const
bool | greaterThan (void const *e1, void const *e2) const
bool | lessThan (void const *e1, void const *e2) const

## Detailed Description

EstimateHeap is a priority queue of Estimate, where the key is the total posteriori probability, and the least costly (highest probability) element is always on top.

Definition at line 40 of file EstimateHeap.h.

## Constructor & Destructor Documentation

EstimateHeap::EstimateHeap | ( | bool | myLargestFirstHeap | ) |

creates a new, empty heap.

Parameters:

  | myLargestFirstHeap | setting this to true makes getFirst return the largest element and false makes getFirst return the least element

Definition at line 37 of file EstimateHeap.cpp.

EstimateHeap::EstimateHeap | ( | EstimateHeap const & | other | ) |

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 45 of file EstimateHeap.cpp.

EstimateHeap::EstimateHeap | ( | EstimateHeap const * | other | ) |

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 53 of file EstimateHeap.cpp.

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

delete this Heap

Definition at line 61 of file EstimateHeap.cpp.

## Member Function Documentation

int EstimateHeap::insert | ( | Estimate * | element | ) |

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 68 of file EstimateHeap.cpp.

Referenced by Mers::Estimation::Discrete::ModeEstimation::ModeEstimator::addEstimate(), and Mers::Estimation::Discrete::CompiledME::CompiledModeEstimator::addEstimate().

int EstimateHeap::peekFirst | ( | Estimate *& | element | ) |

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 75 of file EstimateHeap.cpp.

int EstimateHeap::getFirst | ( | Estimate *& | element | ) |

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 82 of file EstimateHeap.cpp.

Referenced by Mers::Estimation::Discrete::ModeEstimation::ModeEstimator::generateTrajectories(), and Mers::Estimation::Discrete::CompiledME::CompiledModeEstimator::generateTrajectories().

void EstimateHeap::printElement | ( | std::ostream & | out,
|  | void const * | element |
| ) |  |  | const`[virtual]`

prints the heap element to the stream out

Parameters:

  | out | the stream being printed to
  | element | the heap element being printed

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 91 of file EstimateHeap.cpp.

void EstimateHeap::deleteElement | ( | void * | element | ) | const`[protected, virtual]`

Called when an element should be deleted because it's storage space is being deleted. This function deletes the element

Parameters:

  | element | the array entry to delete

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 100 of file EstimateHeap.cpp.

void * EstimateHeap::newElement | ( | void const * | element | ) | const`[protected, virtual]`

Creates and returns a new array object that is a copy of the element passed in.

Parameters:

  | element | the element being copied

Returns:
  the new array object that is a copy of element

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 107 of file EstimateHeap.cpp.

bool EstimateHeap::greaterThan | ( | void const * | e1,
|  | void const * | e2 |
| ) |  |  | const`[protected, 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)

Implements Mers::Utils::Containers::DynamicHeap.

Definition at line 114 of file EstimateHeap.cpp.

bool EstimateHeap::lessThan | ( | void const * | e1,
|  | void const * | e2 |
| ) |  |  | const`[protected, 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)

Implements Mers::Utils::Containers::DynamicHeap.

Definition at line 121 of file EstimateHeap.cpp.

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

- /Users/fpy/titan-1-5-MBARI/Mers/Estimation/Discrete/EstimateHeap.h
- /Users/fpy/titan-1-5-MBARI/Mers/Estimation/Discrete/EstimateHeap.cpp