3ds Max C++ API Reference
LinkedListT< T, TE > Class Template Reference

#include <linklist.h>

+ 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...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed 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.

Constructor & Destructor Documentation

◆ LinkedListT()

LinkedListT ( )
inline
Remarks
Constructor. The list is initialed to NULL and the count is set to 0.
42  {
43  head = tail = NULL;
44  count = 0;
45  }
#define NULL
Definition: autoptr.h:18

◆ ~LinkedListT()

~LinkedListT ( )
inline
Remarks
Destructor.
48  {
49  New();
50  }
void New()
Definition: linklist.h:53

Member Function Documentation

◆ New()

void New ( )
inline
Remarks
The items in the list are deleted. The list is initialed to NULL and the count is set to 0.
54  {
55  while (head)
56  {
57  TE* next = (TE*)head->next;
58  delete head;
59  head = next;
60  }
61  head = tail = NULL;
62  count = 0;
63  }

◆ Count()

int Count ( )
inline
Remarks
Returns the number of items in the list.
65 { return count; }

◆ Append()

void Append ( T &  item)
inline
Remarks
Adds a new item to the end of the list.
Parameters:
T& item

The item to add.
Operators:
73  {
74  TE* entry = new TE(item);
75  if (tail)
76  tail->next = entry;
77  tail = entry;
78  if (!head)
79  head = entry;
80  count++;
81  }

◆ operator[]()

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.
88  {
89  TE* e = head;
90  while (index && e) {
91  e = (TE*)e->next;
92  index--;
93  }
94  // This should never happen, so we'll punt and return...
95  // the head's data
96  if (!e) {
97  DbgAssert(0);
98  return head->data;
99  }
100  return e->data;
101  }
#define DbgAssert(expr)
Definition: assert1.h:82

◆ operator=()

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.
108  {
109  New();
110  for (int i = 0; i < from.Count(); ++i)
111  Append(from[i]);
112  return *this;
113  }
int Count()
Definition: linklist.h:65
void Append(T &item)
Definition: linklist.h:72