ezEngine  Milestone 7
ezListBase< T > Class Template Reference

A List-class, similar to STL::list. More...

#include <List.h>

Inheritance diagram for ezListBase< T >:

Classes

struct  ConstIterator
 base-class for all iterators More...
 
struct  Iterator
 A forward-iterator. Allows sequential access from front-to-back. More...
 
struct  ListElement
 A list-node, containing data and prev/next pointers. More...
 
struct  ListElementBase
 

Public Member Functions

void Clear ()
 Clears the list, afterwards it is empty.
 
ezUInt32 GetCount () const
 Returns the number of elements in the list. O(1) operation.
 
bool IsEmpty () const
 Returns whether size == 0. O(1) operation.
 
const T & PeekFront () const
 Returns the very first element in the list.
 
const T & PeekBack () const
 Returns the very last element in the list.
 
T & PeekFront ()
 Returns the very first element in the list.
 
T & PeekBack ()
 Returns the very last element in the list.
 
void PushBack ()
 Appends a default-constructed element to the list.
 
void PushBack (const T &element)
 Appends a copy of the given element to the list.
 
void PopBack ()
 Removes the very last element from the list.
 
void PushFront ()
 Appends a default-constructed element to the front of the list.
 
void PushFront (const T &element)
 Appends a copy of the given element to the front of the list.
 
void PopFront ()
 Removes the very first element from the list.
 
void SetCount (ezUInt32 uiNewSize)
 Sets the number of elements that are in the list. More...
 
Iterator Insert (const Iterator &pos, const T &data)
 Inserts one element before the position defined by the iterator.
 
void Insert (const Iterator &pos, ConstIterator first, const ConstIterator &last)
 Inserts the range defined by [first;last) after pos.
 
Iterator Remove (const Iterator &pos)
 Erases the element pointed to by the iterator.
 
Iterator Remove (Iterator first, const Iterator &last)
 Erases range [first; last).
 
Iterator GetIterator ()
 Returns an iterator to the first list-element.
 
Iterator GetLastIterator ()
 Returns an iterator to the last list-element. Can be used for reverse iteration.
 
Iterator GetEndIterator ()
 Returns an iterator pointing behind the last element. Necessary if one wants to insert elements at the end of a list.
 
ConstIterator GetIterator () const
 Returns a const-iterator to the first list-element.
 
ConstIterator GetLastIterator () const
 Returns a const-iterator to the last list-element. Can be used for reverse iteration.
 
ConstIterator GetEndIterator () const
 Returns a const-iterator pointing behind the last element. Necessary if one wants to insert elements at the end of a list.
 
ezAllocatorBaseGetAllocator () const
 Returns the allocator that is used by this instance.
 
bool operator== (const ezListBase< T > &rhs) const
 Comparison operator.
 
bool operator!= (const ezListBase< T > &rhs) const
 Comparison operator.
 
ezUInt64 GetHeapMemoryUsage () const
 Returns the amount of bytes that are currently allocated on the heap.
 

Protected Member Functions

 ezListBase (ezAllocatorBase *pAllocator)
 Initializes the list to be empty.
 
 ezListBase (const ezListBase< T > &cc, ezAllocatorBase *pAllocator)
 Initializes the list with a copy from another list.
 
 ~ezListBase ()
 Destroys the list and all its content.
 
void operator= (const ezListBase< T > &cc)
 Copies the list cc into this list.
 

Private Member Functions

ListElementAcquireNode (const T &data)
 Acquires and initializes one node.
 
void ReleaseNode (ListElement *pNode)
 Destructs one node and puts it into the free-list.
 

Private Attributes

ListElementBase m_First
 Sentinel node before the first element.
 
ListElementBase m_Last
 Sentinel node after the last element.
 
Iterator m_End
 
ezUInt32 m_uiCount
 The number of active elements in the list.
 
ezDeque< ListElement,
ezNullAllocatorWrapper, false > 
m_Elements
 Data-Store. Contains all the elements.
 
ListElementm_pFreeElementStack
 Stack that holds recently freed nodes, that can be quickly reused.
 

Detailed Description

template<typename T>
class ezListBase< T >

A List-class, similar to STL::list.

This container class allows fast insertion and erasure of elements. Access is limited to iteration from front-to-back or back-to-front, there is no random-access. Define the type of object to store in the list via the template argument T.

Member Function Documentation

template<typename T >
void ezListBase< T >::SetCount ( ezUInt32  uiNewSize)

Sets the number of elements that are in the list.

If uiNewSize is smaller than the size of the list, elements are popped from the back, until the desired size is reached. If uiNewSize is larger than the size of the list, default-constructed elements are appended to the list, until the desired size is reached.


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