PixelLightAPI  .
Public Member Functions
PLCore::FastPool< ValueType > Class Template Reference

Fast pool class. More...

#include <FastPool.h>

Inheritance diagram for PLCore::FastPool< ValueType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 FastPool ()
 Constructor.
 FastPool (const FastPool< ValueType > &lstSource, uint32 nStart=0, uint32 nCount=0)
 Copy constructor.
 FastPool (const Container< ValueType > &lstSource, uint32 nStart=0, uint32 nCount=0)
 Copy constructor.
virtual ~FastPool ()
 Destructor.
Container< ValueType > & operator= (const FastPool< ValueType > &lstSource)
 Copy operator.
uint32 GetNumOfFreeElements () const
 Returns the number of currently free pool elements.
uint32 GetFreeSize () const
 Returns the total size of all free container elements (in bytes)
void FreeElements ()
 Marks all elements as free.
void RemoveAllFreeElements ()
 Removes all currently free elements.
void RemoveElement (ValueType &cElement)
 Removes an element (added to the list of free elements)
int GetElementIndex (ValueType &cElement) const
 Returns the index of an element.
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 bool IsEmpty () const override
 Checks whether the container is complete empty.
virtual uint32 GetNumOfElements () const override
 Returns the number of elements.
virtual uint32 GetElementSize () const override
 Returns the size of a single container element (in bytes)
virtual uint32 GetSize () const override
 Returns the total size of all container elements (in bytes)
virtual void Clear () override
 Clears the whole container.
virtual bool IsElement (const ValueType &Element) const override
 Returns whether the given element is within the container or not.
virtual int GetIndex (const ValueType &Element) const override
 Returns the index of an element (first appearance)
virtual ValueType & Get (uint32 nIndex) const override
 Returns an element.
virtual ValueType & operator[] (uint32 nIndex) const override
 Returns an element.
virtual bool Replace (const ValueType &Element1, const ValueType &Element2) override
 Replaces an element (first appearance) through another element.
virtual bool ReplaceAtIndex (uint32 nIndex, const ValueType &Element) override
 Replaces an element at the given index through another element.
virtual ValueType & Add () override
 Appends an element to the container.
virtual ValueType & Add (const ValueType &Element) override
 Appends an element to the container.
virtual uint32 Add (const ValueType *pElements, uint32 nCount) override
 Adds elements from a given C-array.
virtual Container< ValueType > & operator+= (const ValueType &Element) override
 Appends an element to the container.
virtual bool Add (const Container< ValueType > &lstContainer, uint32 nStart=0, uint32 nCount=0) override
 Appends an container to this container.
virtual Container< ValueType > & operator+= (const Container< ValueType > &lstContainer) override
 Appends an container to this container.
virtual ValueType & AddAtIndex (int nIndex) override
 Appends an element to the container at the given index.
virtual ValueType & AddAtIndex (const ValueType &Element, int nIndex) override
 Appends an element to the container at the given index.
virtual bool Remove (const ValueType &Element) override
 Removes an element (first appearance) from the container.
virtual bool RemoveAtIndex (uint32 nElement) override
 Removes the element at the given index from the container.
virtual Container< ValueType > & operator-= (const ValueType &Element) override
 Removes an element from the container.
virtual bool Remove (const Container< ValueType > &lstContainer, uint32 nStart=0, uint32 nCount=0) override
 Removes the elements of an container from this container.
virtual Container< ValueType > & operator-= (const Container< ValueType > &lstContainer) override
 Removes the elements of an container from this container.
virtual bool Copy (const Container< ValueType > &lstContainer, uint32 nStart=0, uint32 nCount=0) override
 Makes this container to a copy of another container.
virtual Container< ValueType > & operator= (const Container< ValueType > &lstContainer) override
 Makes this container to a copy of another container.
virtual bool Compare (const Container< ValueType > &lstContainer, uint32 nStart=0, uint32 nCount=0) const override
 Compares two containers.
virtual bool operator== (const Container< ValueType > &lstContainer) const override
 Compares two containers.
virtual bool operator!= (const Container< ValueType > &lstContainer) const override
 Compares two containers.

Detailed Description

template<class ValueType>
class PLCore::FastPool< ValueType >

Fast pool class.

Note:
  • Your elements MUST be derived from FastPoolElement
  • Use RemoveElement() to remove an element in a quite fast way
  • Do NOT use your element within more than one fast pool at once, if this is required, use the pool class instead
See also:

Constructor & Destructor Documentation

template<class ValueType >
PLCore::FastPool< ValueType >::FastPool ( )
template<class ValueType>
PLCore::FastPool< ValueType >::FastPool ( const FastPool< ValueType > &  lstSource,
uint32  nStart = 0,
uint32  nCount = 0 
)

Copy constructor.

Parameters:
[in]lstSourceFast pool to copy from
[in]nStartIndex the copy operation should start
[in]nCountNumber of elements to copy, if 0 copy all elements of lstSource behind nStart
template<class ValueType>
PLCore::FastPool< ValueType >::FastPool ( const Container< ValueType > &  lstSource,
uint32  nStart = 0,
uint32  nCount = 0 
)

Copy constructor.

Parameters:
[in]lstSourceContainer to copy from
[in]nStartIndex the copy operation should start
[in]nCountNumber of elements to copy, if 0 copy all elements of lstSource behind nStart
template<class ValueType >
PLCore::FastPool< ValueType >::~FastPool ( ) [virtual]

Destructor.


Member Function Documentation

template<class ValueType>
Container< ValueType > & PLCore::FastPool< ValueType >::operator= ( const FastPool< ValueType > &  lstSource)

Copy operator.

Parameters:
[in]lstSourceFast pool to copy from
Returns:
Reference to this instance
template<class ValueType >
uint32 PLCore::FastPool< ValueType >::GetNumOfFreeElements ( ) const

Returns the number of currently free pool elements.

Returns:
Number of currently free pool elements
template<class ValueType >
uint32 PLCore::FastPool< ValueType >::GetFreeSize ( ) const

Returns the total size of all free container elements (in bytes)

Returns:
Total size of all free container elements (in bytes)
template<class ValueType >
void PLCore::FastPool< ValueType >::FreeElements ( )

Marks all elements as free.

Note:
  • Quite fast
template<class ValueType >
void PLCore::FastPool< ValueType >::RemoveAllFreeElements ( )

Removes all currently free elements.

template<class ValueType>
void PLCore::FastPool< ValueType >::RemoveElement ( ValueType &  cElement)

Removes an element (added to the list of free elements)

Parameters:
[in]cElementElement to remove, MUST be an element from THIS pool!
Note:
  • If you have the reference to your element, use this function to remove it because it's quite faster than the default Remove() function
template<class ValueType>
int PLCore::FastPool< ValueType >::GetElementIndex ( ValueType &  cElement) const

Returns the index of an element.

Parameters:
[in]cElementElement to get the index from
Returns:
Index of the given element, < 0 if it's not in the container
template<class ValueType >
Iterator< ValueType > PLCore::FastPool< ValueType >::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 ValueType >
ConstIterator< ValueType > PLCore::FastPool< ValueType >::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 ValueType >
Iterator< ValueType > PLCore::FastPool< ValueType >::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 ValueType >
ConstIterator< ValueType > PLCore::FastPool< ValueType >::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 ValueType >
bool PLCore::FastPool< ValueType >::IsEmpty ( ) const [override, virtual]

Checks whether the container is complete empty.

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

Implements PLCore::Container< ValueType >.

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

Returns the number of elements.

Returns:
Number of container elements

Implements PLCore::Container< ValueType >.

template<class ValueType >
uint32 PLCore::FastPool< ValueType >::GetElementSize ( ) const [override, virtual]

Returns the size of a single container element (in bytes)

Returns:
Size of a single container element (in bytes)

Implements PLCore::Container< ValueType >.

template<class ValueType >
uint32 PLCore::FastPool< ValueType >::GetSize ( ) const [override, virtual]

Returns the total size of all container elements (in bytes)

Returns:
Total size of all container elements (in bytes)
Remarks:
You can NOT assume that GetElementSize()*GetNumOfElements() = GetSize() is always true. For instance the Bitset implementation will store the bits tightly packed and therefore in this case GetElementSize()*GetNumOfElements() != GetSize(). GetSize() will only give you a hind how many bytes are currently required to store all elements WITHOUT further implementation dependent things like pointers from one to the next element.

Implements PLCore::Container< ValueType >.

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

Clears the whole container.

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::IsElement ( const ValueType &  Element) const [override, virtual]

Returns whether the given element is within the container or not.

Parameters:
[in]ElementElement to check
Returns:
'true' if the element is within the container, else 'false'

Implements PLCore::Container< ValueType >.

template<class ValueType>
int PLCore::FastPool< ValueType >::GetIndex ( const ValueType &  Element) const [override, virtual]

Returns the index of an element (first appearance)

Parameters:
[in]ElementElement to get the index from
Returns:
Index of the given element, < 0 if it's not in the container

Implements PLCore::Container< ValueType >.

template<class ValueType >
ValueType & PLCore::FastPool< ValueType >::Get ( uint32  nIndex) const [override, virtual]

Returns an element.

Parameters:
[in]nIndexIndex of the element to return
Returns:
Reference to the element at the given index, reference to the 'Null'-object on error

Implements PLCore::Container< ValueType >.

template<class ValueType >
ValueType & PLCore::FastPool< ValueType >::operator[] ( uint32  nIndex) const [override, virtual]

Returns an element.

Parameters:
[in]nIndexIndex of the element to return
Returns:
Reference to the element at the given index, reference to the 'Null'-object on error

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::Replace ( const ValueType &  Element1,
const ValueType &  Element2 
) [override, virtual]

Replaces an element (first appearance) through another element.

Parameters:
[in]Element1Element to replace
[in]Element2The element which should replace the old one
Returns:
'true' if all went fine, else 'false' (maybe 'Element1' is not within the container?)

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::ReplaceAtIndex ( uint32  nIndex,
const ValueType &  Element 
) [override, virtual]

Replaces an element at the given index through another element.

Parameters:
[in]nIndexIndex of the element to replace
[in]ElementThe element which should replace the old one
Returns:
'true' if all went fine, else 'false' (maybe invalid index?)

Implements PLCore::Container< ValueType >.

template<class ValueType >
ValueType & PLCore::FastPool< ValueType >::Add ( ) [override, virtual]

Appends an element to the container.

Returns:
Reference to the new element, reference to the 'Null'-object on error

Implements PLCore::Container< ValueType >.

template<class ValueType>
ValueType & PLCore::FastPool< ValueType >::Add ( const ValueType &  Element) [override, virtual]

Appends an element to the container.

Parameters:
[in]ElementElement to add
Returns:
Reference to the new element, reference to the 'Null'-object on error

Implements PLCore::Container< ValueType >.

template<class ValueType>
uint32 PLCore::FastPool< ValueType >::Add ( const ValueType *  pElements,
uint32  nCount 
) [override, virtual]

Adds elements from a given C-array.

Parameters:
[in]pElementsPointer to C-array with the elements to add, if a null pointer, nothing is done
[in]nCountNumber of elements to add, the given C-array MUST have at least nCount elements!
Returns:
Number of added elements -> if the array is full and resizing is not allowed, this number may differ from the given nCount

Implements PLCore::Container< ValueType >.

template<class ValueType>
Container< ValueType > & PLCore::FastPool< ValueType >::operator+= ( const ValueType &  Element) [override, virtual]

Appends an element to the container.

Parameters:
[in]ElementElement to add
Returns:
This container

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::Add ( const Container< ValueType > &  lstContainer,
uint32  nStart = 0,
uint32  nCount = 0 
) [override, virtual]

Appends an container to this container.

Parameters:
[in]lstContainerContainer to add
[in]nStartIndex the copy operation should start
[in]nCountNumber of elements to copy, if 0 copy all elements of lstContainer behind nStart
Returns:
'true' if all went fine, else 'false'

Implements PLCore::Container< ValueType >.

template<class ValueType>
Container< ValueType > & PLCore::FastPool< ValueType >::operator+= ( const Container< ValueType > &  lstContainer) [override, virtual]

Appends an container to this container.

Parameters:
[in]lstContainerContainer to add
Returns:
This container

Implements PLCore::Container< ValueType >.

template<class ValueType >
ValueType & PLCore::FastPool< ValueType >::AddAtIndex ( int  nIndex) [override, virtual]

Appends an element to the container at the given index.

Parameters:
[in]nIndexIndex were to add the new element, if < 0 add at end, must be <= 'GetNumOfElements()'
Returns:
Reference to the new element, reference to the 'Null'-object on error (maybe invalid index?)
Note:
  • If the given index is equal to 'GetNumOfElements()' the element is appended at the end of the container
  • The container is only enlarged by one element, this means that if 'GetNumOfElements()' is currently 0 and you give an index of 5 the container is NOT automatically resized to 6 elements!

Implements PLCore::Container< ValueType >.

template<class ValueType>
ValueType & PLCore::FastPool< ValueType >::AddAtIndex ( const ValueType &  Element,
int  nIndex 
) [override, virtual]

Appends an element to the container at the given index.

Parameters:
[in]ElementElement to add
[in]nIndexIndex were to add the new element, if < 0 add at end, must be <= 'GetNumOfElements()'
Returns:
Reference to the new element, reference to the 'Null'-object on error (maybe invalid index?)
See also:

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::Remove ( const ValueType &  Element) [override, virtual]

Removes an element (first appearance) from the container.

Parameters:
[in]ElementElement to remove
Returns:
'true' if all went fine, else 'false' (maybe 'Element' is not within the container?)

Implements PLCore::Container< ValueType >.

template<class ValueType >
bool PLCore::FastPool< ValueType >::RemoveAtIndex ( uint32  nElement) [override, virtual]

Removes the element at the given index from the container.

Parameters:
[in]nElementIndex of the element to remove
Returns:
'true' if all went fine, else 'false' (maybe invalid index?)

Implements PLCore::Container< ValueType >.

template<class ValueType>
Container< ValueType > & PLCore::FastPool< ValueType >::operator-= ( const ValueType &  Element) [override, virtual]

Removes an element from the container.

Parameters:
[in]ElementElement to remove
Returns:
This container

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::Remove ( const Container< ValueType > &  lstContainer,
uint32  nStart = 0,
uint32  nCount = 0 
) [override, virtual]

Removes the elements of an container from this container.

Parameters:
[in]lstContainerContainer to remove the elements from this container
[in]nStartIndex the remove operation should start
[in]nCountNumber of elements to remove, if 0 remove all elements of lstContainer behind nStart
Returns:
'true' if all went fine, else 'false'

Implements PLCore::Container< ValueType >.

template<class ValueType>
Container< ValueType > & PLCore::FastPool< ValueType >::operator-= ( const Container< ValueType > &  lstContainer) [override, virtual]

Removes the elements of an container from this container.

Parameters:
[in]lstContainerContainer to remove the elements from this container
Returns:
This container

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::Copy ( const Container< ValueType > &  lstContainer,
uint32  nStart = 0,
uint32  nCount = 0 
) [override, virtual]

Makes this container to a copy of another container.

Parameters:
[in]lstContainerContainer to copy from
[in]nStartIndex the copy operation should start
[in]nCountNumber of elements to copy, if 0 copy all elements of lstContainer behind nStart
Returns:
'true' if all went fine, else 'false'

Implements PLCore::Container< ValueType >.

template<class ValueType>
Container< ValueType > & PLCore::FastPool< ValueType >::operator= ( const Container< ValueType > &  lstContainer) [override, virtual]

Makes this container to a copy of another container.

Parameters:
[in]lstContainerContainer to copy from
Returns:
Reference to this instance

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::Compare ( const Container< ValueType > &  lstContainer,
uint32  nStart = 0,
uint32  nCount = 0 
) const [override, virtual]

Compares two containers.

Parameters:
[in]lstContainerContainer to compare with
[in]nStartIndex the compare operation should start
[in]nCountNumber of elements to compare, if 0 compare all elements of lstContainer behind nStart
Returns:
'true' if both containers are equal, else 'false'

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::operator== ( const Container< ValueType > &  lstContainer) const [override, virtual]

Compares two containers.

Parameters:
[in]lstContainerContainer to compare with
Returns:
'true' if both containers are equal, else 'false'

Implements PLCore::Container< ValueType >.

template<class ValueType>
bool PLCore::FastPool< ValueType >::operator!= ( const Container< ValueType > &  lstContainer) const [override, virtual]

Compares two containers.

Parameters:
[in]lstContainerContainer to compare with
Returns:
'true' if both containers are not equal, else 'false'

Implements PLCore::Container< ValueType >.


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:24
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported