Kaim::SharedPoolList< T > Class Template Reference

Kaim::SharedPoolList< T > Class Template Reference

#include <sharedpoollist.h>

Class Description

template<typename T>
class Kaim::SharedPoolList< T >

SharedPoolList represents an ordered list of elements of a single type, drawn as needed from a pre-allocated pool that you provide.

Template Parameters
TThe type of object to be stored in this list.

Constructing the list

In order to use this class, you must create an instance of SharedPoolList::Pool. You must then set the SharedPoolList to use this pool of objects, either in its constructor or by calling SharedPoolList::SetNodePool(). For example:

typedef SharedPoolList<MyValue> MyList
MyList::NodePool myPool;
MyList myList(&myPool);
// or myList.SetPool(&myPool);

Iterating through the list

To iterate through the elements of the list in ascending order:

for (MyList::ConstIterator it = myList.Begin(); it != myList.End(); ++it)
{
// You can use the * operator to retrieve the instance of your data type currently pointed to by the Iterator:
const MyValue& value = *it;
// ...
}

Public typedefs

typedef SPListNode< T > Node
 
typedef SPL_Iterator< T > Iterator
 
typedef SPL_ConstIterator< T > ConstIterator
 
typedef Pool< SPListNode< T > > NodePool
 
typedef NodePool::Key NodeKey
 

Main API Functions

 SharedPoolList (NodePool *nodePool=nullptr)
 
void SetNodePool (NodePool *nodePool)
 
 ~SharedPoolList ()
 
void Clear ()
 
KyUInt32 GetCount () const
 

Bounds

ConstIterator GetFirst () const
 
ConstIterator GetLast () const
 
Iterator GetFirst ()
 
Iterator GetLast ()
 
ConstIterator Begin () const
 
ConstIterator End () const
 
Iterator Begin ()
 
Iterator End ()
 

Utility Functions

bool IsEmpty () const
 
bool IsFirst (ConstIterator it) const
 
bool IsFirst (Iterator it) const
 
bool IsLast (ConstIterator it) const
 
bool IsLast (Iterator it) const
 
bool IsNull (ConstIterator it) const
 
bool IsNull (Iterator it) const
 
bool IsValid (ConstIterator it) const
 
bool IsValid (Iterator it) const
 
ConstIterator Find (const T &data) const
 
Iterator Find (const T &data)
 

Node Insertion

Iterator InsertBefore (const T &data, Iterator nextNodeIt)
 
Iterator InsertAfter (Iterator prevNodeIt, const T &data)
 
Iterator InsertBefore (Iterator nextNodeIt)
 
Iterator InsertAfter (Iterator prevNodeIt)
 
Iterator PushFront (const T &data)
 
Iterator PushBack (const T &data)
 
Iterator PushFront ()
 
Iterator PushBack ()
 

Node Removal

Iterator Erase (Iterator it)
 
Iterator RemoveFirstOccurrence (Iterator begin, const T &data)
 
KyUInt32 RemoveAllOccurrences (const T &data)
 
template<class Predicate >
KyUInt32 Remove_If (Predicate predicate)
 

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