LinkedListT< T, TE > Class Template Reference

LinkedListT< T, TE > Class Template Reference

#include <linklist.h>

Class Description

template<class T, class TE>
class LinkedListT< T, TE >

Description:
Simple linked list class. Methods and operators are provided to create new linked lists, return the number of items in the list, access item using the array operator ([]), and assign one list to another. All methods of this class are implemented by the system.
+ Inheritance diagram for LinkedListT< T, TE >:

Public Member Functions

 LinkedListT ()
 
 ~LinkedListT ()
 
void New ()
 
int Count ()
 
void Append (T &item)
 
T & operator[] (int index)
 
LinkedListToperator= (LinkedListT &from)
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

LinkedListT ( )
inline
Remarks
Constructor. The list is initialed to NULL and the count is set to 0.
41  {
42  head = tail = NULL;
43  count = 0;
44  }
#define NULL
Definition: autoptr.h:18
~LinkedListT ( )
inline
Remarks
Destructor.
47  {
48  New();
49  }
void New()
Definition: linklist.h:52

Member Function Documentation

void New ( )
inline
Remarks
The items in the list are deleted. The list is initialed to NULL and the count is set to 0.
53  {
54  while(head)
55  {
56  TE* next = (TE*)head->next;
57  delete head;
58  head = next;
59  }
60  head = tail = NULL;
61  count = 0;
62  }
#define NULL
Definition: autoptr.h:18
int Count ( )
inline
Remarks
Returns the number of items in the list.
64 { return count; }
void Append ( T &  item)
inline
Remarks
Adds a new item to the end of the list.
Parameters:
T& item

The item to add.
Operators:
72  {
73  TE* entry = new TE(item);
74  if(tail)
75  tail->next = entry;
76  tail = entry;
77  if(!head)
78  head = entry;
79  count++;
80  }
T& operator[] ( int  index)
inline
Remarks
Allows access to items in the list using the array operator. The first item in the list has an index of 0.
Parameters:
int index

The array index of the item to access.
87  {
88  TE* e = head;
89  while(index && e) {
90  e = (TE*)e->next;
91  index--;
92  }
93  // This should never happen, so we'll punt and return...
94  // the head's data
95  if(!e) {
96  DbgAssert(0);
97  return head->data;
98  }
99  return e->data;
100  }
#define DbgAssert(expr)
Definition: assert1.h:72
LinkedListT& operator= ( LinkedListT< T, TE > &  from)
inline
Remarks
Assignment operator.
Parameters:
LinkedListT &from

The list to copy.
Returns
A new linked list that is a copy of the list passed.
107  {
108  New();
109  for(int i = 0; i < from.Count(); ++i)
110  Append(from[i]);
111  return *this;
112  }
void New()
Definition: linklist.h:52
int Count()
Definition: linklist.h:64
void Append(T &item)
Definition: linklist.h:71