Ocular Engine
Ocular::Utils::PriorityList< T, MAX_ELEMENTS > Class Template Reference

Public Member Functions

bool push (T const element, uint32_t priority)
 
bool pop ()
 
bool add (T const element, uint32_t priority)
 
void removeElement (T const element)
 
void removeIndex (uint32_t index)
 
T const get (std::size_t index) const
 
std::size_t size () const
 
std::size_t maxSize () const
 
bool empty () const
 
bool contains (T const element) const
 
void clear ()
 

Protected Member Functions

void insertElement (T const element, uint32_t const priority)
 
void deleteElement (std::size_t const index)
 
void shiftLeft (std::size_t const index)
 
void shiftRight (std::size_t const index)
 
std::size_t locateIndex (T const element) const
 
std::size_t findIndex (uint32_t const priority) const
 
std::size_t binaryFind (uint32_t const priority) const
 

Member Function Documentation

template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::add ( T const  element,
uint32_t  priority 
)
inline

Attempts to add the provided element into the priority list.

Parameters
[in]element
[in]priorityPriority level of the element. Lower is higher priority.
Returns
TRUE if successfully inserted, else FALSE. May only fail if list if full.
template<typename T, std::size_t MAX_ELEMENTS>
std::size_t Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::binaryFind ( uint32_t const  priority) const
inlineprotected

Performs a binary search on the internal priority list and returns the best fit index for the given priority level.

template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::clear ( )
inline

Removes all elements from the list.

template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::contains ( T const  element) const
inline
Returns
TRUE if the list contains an element that matches the one specified.
template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::deleteElement ( std::size_t const  index)
inlineprotected

Removes the element at the specified index from the internal array.

template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::empty ( ) const
inline
Returns
TRUE if list is empty
template<typename T, std::size_t MAX_ELEMENTS>
std::size_t Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::findIndex ( uint32_t const  priority) const
inlineprotected

Finds and returns the index that best fits the given priority level.

template<typename T, std::size_t MAX_ELEMENTS>
T const Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::get ( std::size_t  index) const
inline
Returns
The element at the specified index. If the element (or the index) does not exist, then null is returned.
template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::insertElement ( T const  element,
uint32_t const  priority 
)
inlineprotected

Inserts the element into the specified index into the internal array.

template<typename T, std::size_t MAX_ELEMENTS>
std::size_t Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::locateIndex ( T const  element) const
inlineprotected

Finds and returns the index that matches the provided element.
If the element is not found, return MAX_ELEMENTS.

template<typename T, std::size_t MAX_ELEMENTS>
std::size_t Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::maxSize ( ) const
inline
Returns
Maximum number of elements possible to track.
template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::pop ( )
inline

Removes the element with highest priority.

Returns
TRUE if pop was successful.
template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::push ( T const  element,
uint32_t  priority 
)
inline

Pushes the element onto the list.

Parameters
[in]element
[in]priorityPriority level of the element. Lower is higher priority.
Returns
TRUE if push was successful.
template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::removeElement ( T const  element)
inline

Removes the specified element if it exists.

template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::removeIndex ( uint32_t  index)
inline

Removes the element at the specified index.
Throws an exception if index is out of bounds.

template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::shiftLeft ( std::size_t const  index)
inlineprotected

Shifts all elements from the provided index and onwards to the left.
Used in element removal.

template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::shiftRight ( std::size_t const  index)
inlineprotected

Shifts all elements from the provided index and onwards to the right.
Used in element insertion.

template<typename T, std::size_t MAX_ELEMENTS>
std::size_t Ocular::Utils::PriorityList< T, MAX_ELEMENTS >::size ( ) const
inline
Returns
Number of elements currently tracked.

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