F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
|
A stable max heap data structure. More...
#include <Os/Pthreads/MaxHeap/MaxHeap.hpp>
Public Member Functions | |
MaxHeap () | |
MaxHeap constructor. | |
~MaxHeap () | |
MaxHeap deconstructor. | |
bool | create (NATIVE_UINT_TYPE capacity) |
MaxHeap creation. | |
bool | push (NATIVE_INT_TYPE value, NATIVE_UINT_TYPE id) |
Push an item onto the heap. | |
bool | pop (NATIVE_INT_TYPE &value, NATIVE_UINT_TYPE &id) |
Pop an item from the heap. | |
bool | isFull () |
Is the heap full? | |
bool | isEmpty () |
Is the heap empty? | |
NATIVE_UINT_TYPE | getSize () |
Get the current number of elements on the heap. | |
void | print () |
Print the contents of the heap to stdout. | |
A stable max heap data structure.
This is a max heap data structure. Items of the highest value will be popped off the heap first. Items of equal value will be popped off in FIFO order. Insertion and deletion from the heap are both O(log(n)) time.
Definition at line 27 of file MaxHeap.hpp.
Os::MaxHeap::MaxHeap | ( | ) |
Os::MaxHeap::~MaxHeap | ( | ) |
MaxHeap deconstructor.
Free memory for the heap that was allocated in the constructor
Definition at line 40 of file MaxHeap.cpp.
bool Os::MaxHeap::create | ( | NATIVE_UINT_TYPE | capacity | ) |
MaxHeap creation.
Create the max heap with a given maximum size
capacity | the maximum number of elements to store in the heap |
Definition at line 45 of file MaxHeap.cpp.
NATIVE_UINT_TYPE Os::MaxHeap::getSize | ( | ) |
Get the current number of elements on the heap.
This function returns the current number of items on the heap.
Definition at line 150 of file MaxHeap.cpp.
bool Os::MaxHeap::isEmpty | ( | ) |
Is the heap empty?
Is the heap empty? No item can be popped from the heap if this function returns true.
Definition at line 145 of file MaxHeap.cpp.
bool Os::MaxHeap::isFull | ( | ) |
Is the heap full?
Has the heap reached max size. No new items can be put on the heap if this function returns true.
Definition at line 140 of file MaxHeap.cpp.
bool Os::MaxHeap::pop | ( | NATIVE_INT_TYPE & | value, |
NATIVE_UINT_TYPE & | id | ||
) |
Pop an item from the heap.
The item with the maximum value in the heap will be returned. If there are items with equal values, the oldest item will be returned.
value | the value of the element to popped from the heap |
id | the identifier of the element popped from the heap |
Definition at line 111 of file MaxHeap.cpp.
void Os::MaxHeap::print | ( | ) |
Print the contents of the heap to stdout.
This function here is for debugging purposes.
Definition at line 262 of file MaxHeap.cpp.
bool Os::MaxHeap::push | ( | NATIVE_INT_TYPE | value, |
NATIVE_UINT_TYPE | id | ||
) |
Push an item onto the heap.
The item will be put into the heap according to its value. The id field is a data field set by the user which can be used to identify the element when it is popped off the heap.
value | the value of the element to push onto the heap |
id | the identifier of the element to push onto the heap |
Definition at line 62 of file MaxHeap.cpp.