ListT< T > Class Template Reference

Generic List. More...

#include <genlist.h>

List of all members.

Public Types

typedef T ValueType
typedef Allocator< T > ValueAllocatorType
typedef Allocator< T >::Pointer Pointer
typedef Allocator< T >::Reference Reference
typedef Allocator< T >::ConstReference ConstReference
typedef Allocator< ListNodeListNodeAllocatorType
typedef Allocator< ListNode
>::Pointer 
LinkType
typedef Allocator< ListNode
>::SizeType 
SizeType
typedef Allocator< ListNode
>::DifferenceType 
DifferenceType

Public Member Functions

 ListT ()
BOOL IsValid () const
Iterator Begin ()
ConstIterator Begin () const
Iterator End ()
ConstIterator End () const
BOOL Empty () const
SizeType Size () const
Reference Front ()
ConstReference Front () const
Reference Back ()
ConstReference Back () const
Iterator Insert (Iterator Position, const T &X)
BOOL PushBack (const T &X)
void Erase (Iterator Position)
void Erase (Iterator First, Iterator Last)
void PopBack ()
 ~ListT ()

Protected Types

typedef Allocator< void
>::Pointer 
VoidPointer

Protected Member Functions

LinkType GetNode ()
void PutNode (LinkType p)

Protected Attributes

SizeType m_NumberOfLists
LinkType m_Node
SizeType m_Length
BOOL m_bIsValid

Static Protected Attributes

static ListNodeAllocatorType g_ListNodeAllocator
static ValueAllocatorType g_ValueAllocator

Friends

struct ListNode

Classes

class  ConstIterator
class  Iterator
struct  ListNode


Detailed Description

template<typename T>
class ListT< T >

Generic List.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from STL)
Date:
20/12/96

Definition at line 126 of file genlist.h.


Member Typedef Documentation

template<typename T>
typedef Allocator<T>::ConstReference ListT< T >::ConstReference
 

Definition at line 147 of file genlist.h.

template<typename T>
typedef Allocator<ListNode>::DifferenceType ListT< T >::DifferenceType
 

Definition at line 152 of file genlist.h.

template<typename T>
typedef Allocator<ListNode>::Pointer ListT< T >::LinkType
 

Definition at line 150 of file genlist.h.

template<typename T>
typedef Allocator<ListNode> ListT< T >::ListNodeAllocatorType
 

Definition at line 149 of file genlist.h.

template<typename T>
typedef Allocator<T>::Pointer ListT< T >::Pointer
 

Definition at line 145 of file genlist.h.

template<typename T>
typedef Allocator<T>::Reference ListT< T >::Reference
 

Definition at line 146 of file genlist.h.

template<typename T>
typedef Allocator<ListNode>::SizeType ListT< T >::SizeType
 

Definition at line 151 of file genlist.h.

template<typename T>
typedef Allocator<T> ListT< T >::ValueAllocatorType
 

Definition at line 144 of file genlist.h.

template<typename T>
typedef T ListT< T >::ValueType
 

Definition at line 142 of file genlist.h.

template<typename T>
typedef Allocator<void>::Pointer ListT< T >::VoidPointer [protected]
 

Definition at line 129 of file genlist.h.


Constructor & Destructor Documentation

template<typename T>
ListT< T >::ListT  )  [inline]
 

Definition at line 321 of file genlist.h.

00321             : m_NumberOfLists(0), m_Length(0) //,free_list(0), buffer_list(0), next_avail(0), last(0), 
00322     { 
00323         ++m_NumberOfLists;
00324         m_Node = GetNode();
00325         if (m_Node != NULL)
00326         {
00327             (*m_Node).next = m_Node;
00328             (*m_Node).prev = m_Node;
00329             m_bIsValid = TRUE;
00330         }
00331         else
00332         {
00333             m_bIsValid = FALSE;
00334         }
00335     }

template<typename T>
ListT< T >::~ListT  )  [inline]
 

Definition at line 440 of file genlist.h.

00441     {
00442         Erase(Begin(), End());
00443         PutNode(m_Node);
00444 //      if (--m_NumberOfLists == 0)
00445 //      {
00446 //          deallocate_buffers();
00447 //      }
00448     }


Member Function Documentation

template<typename T>
ConstReference ListT< T >::Back  )  const [inline]
 

Definition at line 361 of file genlist.h.

00361 { return *(--End()); }

template<typename T>
Reference ListT< T >::Back  )  [inline]
 

Definition at line 360 of file genlist.h.

00360 { return *(--End()); }

template<typename T>
ConstIterator ListT< T >::Begin  )  const [inline]
 

Definition at line 340 of file genlist.h.

00340 { return (LinkType)((*m_Node).next); }

template<typename T>
Iterator ListT< T >::Begin  )  [inline]
 

Definition at line 339 of file genlist.h.

00339 { return (LinkType)((*m_Node).next); }

template<typename T>
BOOL ListT< T >::Empty  )  const [inline]
 

Definition at line 353 of file genlist.h.

00353 { return m_Length == 0; }

template<typename T>
ConstIterator ListT< T >::End  )  const [inline]
 

Definition at line 342 of file genlist.h.

00342 { return m_Node; }

template<typename T>
Iterator ListT< T >::End  )  [inline]
 

Definition at line 341 of file genlist.h.

00341 { return m_Node; }

template<class T>
void ListT< T >::Erase Iterator  First,
Iterator  Last
 

Definition at line 570 of file genlist.h.

00571 {
00572     while (!(First == Last))
00573     {
00574         Erase(First++);
00575     }
00576 }

template<typename T>
void ListT< T >::Erase Iterator  Position  )  [inline]
 

Definition at line 395 of file genlist.h.

00396     {
00397         if (m_Length != 0)
00398         {
00399             (*(LinkType((*Position.m_Node).prev))).next = (*Position.m_Node).next;
00400             (*(LinkType((*Position.m_Node).next))).prev = (*Position.m_Node).prev;
00401             Destroy(g_ValueAllocator.Address((*Position.m_Node).data));
00402             PutNode(Position.m_Node);
00403             --m_Length;
00404         }
00405         else
00406         {
00407             ERROR3("Erase from Empty ListT");
00408         }
00409     }

template<typename T>
ConstReference ListT< T >::Front  )  const [inline]
 

Definition at line 359 of file genlist.h.

00359 { return *(Begin()); }      // ++?

template<typename T>
Reference ListT< T >::Front  )  [inline]
 

Definition at line 358 of file genlist.h.

00358 { return *(Begin()); }      // ++?

template<typename T>
LinkType ListT< T >::GetNode  )  [inline, protected]
 

Definition at line 194 of file genlist.h.

00195     {
00196         return new ListNode;
00197 /*  Extended Mix
00198         LinkType NodeToReturn;
00199         if (m_FreeList != NULL)
00200         {
00201             LinkType tmp = m_FreeList;
00202             m_FreeList = (LinkType)m_FreeList->next;
00203             NodeToReturn = tmp;
00204         }
00205         else
00206         {
00207             if (m_NextAvail == m_Last)
00208             {
00209                 AddNewBuffer();
00210             }
00211             NodeToReturn = m_NextAvail++;
00212         }
00213         return NodeToReturn;
00214     }
00215 */
00216 //      return free_list ? (free_list = (link_type)(free_list->next), tmp) 
00217 //                  : (next_avail == last ? (add_new_buffer(), next_avail++) : next_avail++);
00218     // ugly code for inlining - avoids multiple returns
00219     }

template<typename T>
Iterator ListT< T >::Insert Iterator  Position,
const T &  X
[inline]
 

Definition at line 368 of file genlist.h.

00369     {
00370         LinkType tmp = GetNode();
00371         if (tmp != NULL)
00372         {
00373             Construct(g_ValueAllocator.Address((*tmp).data), X);
00374             (*tmp).next = Position.m_Node;
00375             (*tmp).prev = (*Position.m_Node).prev;
00376             (*(LinkType((*Position.m_Node).prev))).next = tmp;
00377             (*Position.m_Node).prev = tmp;
00378             ++m_Length;
00379         }
00380         return tmp;
00381     }

template<typename T>
BOOL ListT< T >::IsValid  )  const [inline]
 

Definition at line 337 of file genlist.h.

00337 {   return m_bIsValid;  }

template<typename T>
void ListT< T >::PopBack  )  [inline]
 

Definition at line 412 of file genlist.h.

00413     { 
00414         Iterator tmp = End();
00415         Erase(--tmp);
00416     }

template<typename T>
BOOL ListT< T >::PushBack const T &  X  )  [inline]
 

Definition at line 389 of file genlist.h.

00390     {
00391         return (Insert(End(), X).m_Node != NULL);
00392     }

template<typename T>
void ListT< T >::PutNode LinkType  p  )  [inline, protected]
 

Definition at line 220 of file genlist.h.

00221     {
00222         delete p;
00223 //      p->next = free_list;
00224 //      free_list = p;
00225     }

template<typename T>
SizeType ListT< T >::Size  )  const [inline]
 

Definition at line 354 of file genlist.h.

00354 { return m_Length; }


Friends And Related Function Documentation

template<typename T>
friend struct ListNode [friend]
 

Definition at line 131 of file genlist.h.


Member Data Documentation

template<typename T>
ListT< T >::ListNodeAllocatorType ListT< T >::g_ListNodeAllocator [static, protected]
 

Definition at line 155 of file genlist.h.

template<typename T>
ListT< T >::ValueAllocatorType ListT< T >::g_ValueAllocator [static, protected]
 

Definition at line 156 of file genlist.h.

template<typename T>
BOOL ListT< T >::m_bIsValid [protected]
 

Definition at line 230 of file genlist.h.

template<typename T>
SizeType ListT< T >::m_Length [protected]
 

Definition at line 229 of file genlist.h.

template<typename T>
LinkType ListT< T >::m_Node [protected]
 

Definition at line 228 of file genlist.h.

template<typename T>
SizeType ListT< T >::m_NumberOfLists [protected]
 

Definition at line 191 of file genlist.h.


The documentation for this class was generated from the following file:
Generated on Sat Nov 10 03:56:02 2007 for Camelot by  doxygen 1.4.4