se_core::SinglyLinkedList< ElementType, maxElements, xid > Class Template Reference

Singly linked list manager. More...

#include <SinglyLinkedList.hpp>

List of all members.

Public Types

typedef int iterator_type

Public Member Functions

 SinglyLinkedList (const char *name)
 Constructor.
virtual ~SinglyLinkedList ()
 Destructor.
void add (ElementType *element, iterator_type &firstNode)
 Add member to a list.
ElementType * remove (iterator_type &iterator, const iterator_type &previousElement)
 Remove a member from the the list.
ElementType * pop (iterator_type &iterator)
 Remove and return topmost element in list.
bool remove (ElementType *element, iterator_type &firstNode)
 Remove an element from the list.
void removeChain (iterator_type &firstNode)
 Remove the chain Remove all members from the singly linked list.
bool hasElement (ElementType *element, iterator_type &firstNode)
 Check if an element exists in a singly linked list.
ElementType * next (iterator_type &iterator)
 Iterate to the next member of a singly linked list The iterator is a iterator_type value that should initially have the index of the first node in the list as its value.
int size (const iterator_type &firstNode)
 The number of members in a list.
int capacity ()
bool isFree (const iterator_type &it)
void clear ()
 Remove all singly linked lists.

Static Public Member Functions

const iterator_type end ()
 Returns the value that terminates the loop.

Protected Member Functions

 DebugExec (int count_)

Protected Attributes

const char * name_
 The name of this container instance (included to ease debugging).


Detailed Description

template<class ElementType, int maxElements, int xid>
class se_core::SinglyLinkedList< ElementType, maxElements, xid >

Singly linked list manager.

Stores multiple singly linked lists in a single fixed size array. The approach makes memory usage efficient for MultiSimObject and similar classes without introducing the overhead of allocation, resizing and deallocation of memory buffers on creation or destruction of the list or when deleting or adding members to the list.

Definition at line 38 of file SinglyLinkedList.hpp.


Member Typedef Documentation

template<class ElementType, int maxElements, int xid>
typedef int se_core::SinglyLinkedList< ElementType, maxElements, xid >::iterator_type
 

Definition at line 40 of file SinglyLinkedList.hpp.


Constructor & Destructor Documentation

template<class ElementType, int maxElements, int xid>
se_core::SinglyLinkedList< ElementType, maxElements, xid >::SinglyLinkedList const char *  name  )  [inline]
 

Constructor.

Parameters:
name The name of the singly linked list (for debug purposes)

Definition at line 47 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
virtual se_core::SinglyLinkedList< ElementType, maxElements, xid >::~SinglyLinkedList  )  [inline, virtual]
 

Destructor.

Definition at line 59 of file SinglyLinkedList.hpp.


Member Function Documentation

template<class ElementType, int maxElements, int xid>
void se_core::SinglyLinkedList< ElementType, maxElements, xid >::add ElementType *  element,
iterator_type firstNode
[inline]
 

Add member to a list.

The member will be added to the beginning of the list for efficiency reasons.

Parameters:
element the element to add
firstNode a reference to a variable containint the index of the first node in the list (or end() if it is a new or empty list)

Definition at line 74 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
int se_core::SinglyLinkedList< ElementType, maxElements, xid >::capacity  )  [inline]
 

Definition at line 297 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
void se_core::SinglyLinkedList< ElementType, maxElements, xid >::clear  )  [inline]
 

Remove all singly linked lists.

Removes all singly linked lists contained in the structure.

Definition at line 317 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
se_core::SinglyLinkedList< ElementType, maxElements, xid >::DebugExec int  count_  )  [protected]
 

template<class ElementType, int maxElements, int xid>
const iterator_type se_core::SinglyLinkedList< ElementType, maxElements, xid >::end  )  [inline, static]
 

Returns the value that terminates the loop.

Definition at line 273 of file SinglyLinkedList.hpp.

Referenced by se_ogre::ThingMOList::Iterator::hasNext(), and se_ogre::MultiO3dThingComponent::Iterator::hasNext().

template<class ElementType, int maxElements, int xid>
bool se_core::SinglyLinkedList< ElementType, maxElements, xid >::hasElement ElementType *  element,
iterator_type firstNode
[inline]
 

Check if an element exists in a singly linked list.

Parameters:
element element to look for
firstNode a reference to a variable containing the index of the first node in the list (or end() if it is a new or empty list)

Definition at line 228 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
bool se_core::SinglyLinkedList< ElementType, maxElements, xid >::isFree const iterator_type it  )  [inline]
 

Definition at line 301 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
ElementType* se_core::SinglyLinkedList< ElementType, maxElements, xid >::next iterator_type iterator  )  [inline]
 

Iterate to the next member of a singly linked list The iterator is a iterator_type value that should initially have the index of the first node in the list as its value.

Each time this method is called, the iterator is changed to point to the next member.

Parameters:
iterator a reference to a variable pointing to the current member in the list. After the call it will contain the index of the next member, or end() if no more members exist.

Definition at line 253 of file SinglyLinkedList.hpp.

Referenced by se_core::HashTable< T, poolSize >::lookupNode().

template<class ElementType, int maxElements, int xid>
ElementType* se_core::SinglyLinkedList< ElementType, maxElements, xid >::pop iterator_type iterator  )  [inline]
 

Remove and return topmost element in list.

Definition at line 132 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
bool se_core::SinglyLinkedList< ElementType, maxElements, xid >::remove ElementType *  element,
iterator_type firstNode
[inline]
 

Remove an element from the list.

Will only remove the element from the list once. If the member may exist in the list multiple times, the method must be called once for each instance to remove.

Parameters:
element The elemnt to remove
firstNode a reference to a variable containint the index of the first node in the list (or end() if it is a new or empty list)

Definition at line 162 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
ElementType* se_core::SinglyLinkedList< ElementType, maxElements, xid >::remove iterator_type iterator,
const iterator_type previousElement
[inline]
 

Remove a member from the the list.

: This should be protected.

Definition at line 105 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
void se_core::SinglyLinkedList< ElementType, maxElements, xid >::removeChain iterator_type firstNode  )  [inline]
 

Remove the chain Remove all members from the singly linked list.

Parameters:
firstNode a reference to a variable containint the index of the first node in the list (or end() if it is a new or empty list)

Definition at line 199 of file SinglyLinkedList.hpp.

template<class ElementType, int maxElements, int xid>
int se_core::SinglyLinkedList< ElementType, maxElements, xid >::size const iterator_type firstNode  )  [inline]
 

The number of members in a list.

Parameters:
firstNode a reference to a variable containing the index of the first node in the list (or end() if it is a new or empty list)
Returns:
the number of members

Definition at line 285 of file SinglyLinkedList.hpp.


Member Data Documentation

template<class ElementType, int maxElements, int xid>
const char* se_core::SinglyLinkedList< ElementType, maxElements, xid >::name_ [protected]
 

The name of this container instance (included to ease debugging).

Definition at line 363 of file SinglyLinkedList.hpp.


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

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:30 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo