PixelLightAPI  .
Public Member Functions
PLCore::BinaryHeap< KeyType, ValueType, Comparer > Class Template Reference

Binary heap (arrayed) More...

#include <BinaryHeap.h>

Inheritance diagram for PLCore::BinaryHeap< KeyType, ValueType, Comparer >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 BinaryHeap (uint32 nResizeCount=16)
 Constructor.
virtual ~BinaryHeap ()
 Destructor.
uint32 GetResizeCount () const
 Returns the number of elements automatically added if the binary heap size is to small.
bool SetResizeCount (uint32 nCount=16)
 Sets the number of elements automatically added if the binary heap size is to small.
void Reset ()
 Resets the binary heap.
virtual Iterator< ValueType > GetIterator (uint32 nIndex=0) const override
 Returns an iterator operating on the derived data structure.
virtual ConstIterator< ValueType > GetConstIterator (uint32 nIndex=0) const override
 Returns a constant iterator operating on the derived data structure.
virtual Iterator< ValueType > GetEndIterator () const override
 Returns an iterator operating on the derived data structure and starting at the end.
virtual ConstIterator< ValueType > GetConstEndIterator () const override
 Returns a constant iterator operating on the derived data structure and starting at the end.
virtual void Clear () override
 Clears the heap.
virtual bool IsEmpty () const override
 Checks whether the heap is complete empty.
virtual uint32 GetNumOfElements () const override
 Returns the number of elements.
virtual bool Add (const KeyType &Key, const ValueType &Value) override
 Adds a new element to the heap.
virtual bool GetTop (ValueType *pValue=nullptr, KeyType *pKey=nullptr) const override
 Returns the value of the top element.
virtual bool ExtractTop (ValueType *pValue=nullptr, KeyType *pKey=nullptr) override
 Returns the value of the top element and removes it from the heap.

Detailed Description

template<class KeyType, class ValueType, class Comparer = CompareFunction>
class PLCore::BinaryHeap< KeyType, ValueType, Comparer >

Binary heap (arrayed)

Remarks:
Node: Elements[i*2] Left child: Elements[i*2+1] Right child: Elements[i*2+2]

Constructor & Destructor Documentation

template<class KeyType , class ValueType , class Comparer >
PLCore::BinaryHeap< KeyType, ValueType, Comparer >::BinaryHeap ( uint32  nResizeCount = 16)

Constructor.

Parameters:
[in]nResizeCountResize count
template<class KeyType , class ValueType , class Comparer >
PLCore::BinaryHeap< KeyType, ValueType, Comparer >::~BinaryHeap ( ) [virtual]

Destructor.


Member Function Documentation

template<class KeyType , class ValueType , class Comparer >
uint32 PLCore::BinaryHeap< KeyType, ValueType, Comparer >::GetResizeCount ( ) const

Returns the number of elements automatically added if the binary heap size is to small.

Returns:
Number of elements automatically added if the binary heap size is to small
template<class KeyType , class ValueType , class Comparer >
bool PLCore::BinaryHeap< KeyType, ValueType, Comparer >::SetResizeCount ( uint32  nCount = 16)

Sets the number of elements automatically added if the binary heap size is to small.

Parameters:
[in]nCountNumber of elements automatically added if the binary heap size is to small
Returns:
'true' if all went fine, else 'false'
Note:
  • If nCount is 0, the binary heap size isn't changed automatically
template<class KeyType , class ValueType , class Comparer >
void PLCore::BinaryHeap< KeyType, ValueType, Comparer >::Reset ( )

Resets the binary heap.

Remarks:
While the Clear() function destroys also the data, this function will only reset the current number of elements within the array to 0.
template<class KeyType , class ValueType , class Comparer >
Iterator< ValueType > PLCore::BinaryHeap< KeyType, ValueType, Comparer >::GetIterator ( uint32  nIndex = 0) const [override, virtual]

Returns an iterator operating on the derived data structure.

Parameters:
[in]nIndexStart index, if >= 'total number of elements' the index is set to the last valid index
Returns:
Iterator operating on the derived

Implements PLCore::Iterable< ValueType >.

template<class KeyType , class ValueType , class Comparer >
ConstIterator< ValueType > PLCore::BinaryHeap< KeyType, ValueType, Comparer >::GetConstIterator ( uint32  nIndex = 0) const [override, virtual]

Returns a constant iterator operating on the derived data structure.

Parameters:
[in]nIndexStart index, if >= 'total number of elements' the index is set to the last valid index
Returns:
Constant iterator operating on the derived

Implements PLCore::Iterable< ValueType >.

template<class KeyType , class ValueType , class Comparer >
Iterator< ValueType > PLCore::BinaryHeap< KeyType, ValueType, Comparer >::GetEndIterator ( ) const [override, virtual]

Returns an iterator operating on the derived data structure and starting at the end.

Returns:
Iterator operating on the derived,
Remarks:
Use this function to get an iterator if you want to iterate in reversed order starting at the end last element.

Implements PLCore::Iterable< ValueType >.

template<class KeyType , class ValueType , class Comparer >
ConstIterator< ValueType > PLCore::BinaryHeap< KeyType, ValueType, Comparer >::GetConstEndIterator ( ) const [override, virtual]

Returns a constant iterator operating on the derived data structure and starting at the end.

Returns:
Constant iterator operating on the derived,
Remarks:
Use this function to get a constant iterator if you want to iterate in reversed order starting at the end last element.

Implements PLCore::Iterable< ValueType >.

template<class KeyType , class ValueType , class Comparer >
void PLCore::BinaryHeap< KeyType, ValueType, Comparer >::Clear ( ) [override, virtual]

Clears the heap.

Implements PLCore::Heap< KeyType, ValueType >.

template<class KeyType , class ValueType , class Comparer >
bool PLCore::BinaryHeap< KeyType, ValueType, Comparer >::IsEmpty ( ) const [override, virtual]

Checks whether the heap is complete empty.

Returns:
'true' if the heap is empty, else 'false'

Implements PLCore::Heap< KeyType, ValueType >.

template<class KeyType , class ValueType , class Comparer >
uint32 PLCore::BinaryHeap< KeyType, ValueType, Comparer >::GetNumOfElements ( ) const [override, virtual]

Returns the number of elements.

Returns:
Number of container elements

Implements PLCore::Heap< KeyType, ValueType >.

template<class KeyType, class ValueType, class Comparer >
bool PLCore::BinaryHeap< KeyType, ValueType, Comparer >::Add ( const KeyType &  Key,
const ValueType &  Value 
) [override, virtual]

Adds a new element to the heap.

Parameters:
[in]KeyThe key of the new element
[in]ValueThe value of the new element
Returns:
'true' if all went fine, else 'false'
Note:
  • You have to check by yourself whether there's already such a key within the heap

Implements PLCore::Heap< KeyType, ValueType >.

template<class KeyType, class ValueType, class Comparer >
bool PLCore::BinaryHeap< KeyType, ValueType, Comparer >::GetTop ( ValueType *  pValue = nullptr,
KeyType *  pKey = nullptr 
) const [override, virtual]

Returns the value of the top element.

Parameters:
[out]pValueIf not a null pointer, this will receive the value of the top element
[out]pKeyIf not a null pointer, this will receive the key of the top element
Returns:
'true' if all went fine, else 'false'

Implements PLCore::Heap< KeyType, ValueType >.

template<class KeyType, class ValueType, class Comparer >
bool PLCore::BinaryHeap< KeyType, ValueType, Comparer >::ExtractTop ( ValueType *  pValue = nullptr,
KeyType *  pKey = nullptr 
) [override, virtual]

Returns the value of the top element and removes it from the heap.

Parameters:
[out]pValueIf not a null pointer, this will receive the value of the top element
[out]pKeyIf not a null pointer, this will receive the key of the top element
Returns:
'true' if all went fine, else 'false'

Implements PLCore::Heap< KeyType, ValueType >.


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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:13
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported