3ds Max C++ API Reference
Loading...
Searching...
No Matches
Stack< T > Class Template Reference

A simple stack implementation. More...

#include <stack.h>

+ Inheritance diagram for Stack< T >:

Public Member Functions

const T & operator[] (const int i) const
 
T & operator[] (const int i)
 
void Push (T *el)
 
void Pop (T *el)
 
void Pop ()
 
void GetTop (T *el)
 
void Clear ()
 
int Count () const
 
int Remove (int i)
 

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator.
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator.
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary.
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary.
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc.
 

Detailed Description

template<class T>
class Stack< T >

A simple stack implementation.

Member Function Documentation

◆ operator[]() [1/2]

const T & operator[] ( const int  i) const
inline
26 {
27 DbgAssert(s.Count()-i>0);
28 return s[s.Count()-i-1];
29 }
#define DbgAssert(expr)
Definition: assert1.h:83

◆ operator[]() [2/2]

T & operator[] ( const int  i)
inline
30 {
31 DbgAssert(s.Count()-i>0);
32 return s[s.Count()-i-1];
33 }

◆ Push()

void Push ( T *  el)
inline
Remarks
Pushes the specified element on the stack.
Parameters:
T *el

The item to push.
39 {
40 s.Append( 1, el );
41 }

◆ Pop() [1/2]

void Pop ( T *  el)
inline
Remarks
Pops an item off the stack.
Parameters:
T *el

The item popped off the stack is returned here.
47 {
48 DbgAssert( s.Count() );
49 *el = s[s.Count()-1];
50 s.Delete( s.Count()-1, 1 );
51 }

◆ Pop() [2/2]

void Pop ( )
inline
Remarks
Pops an item off the stack and discards it. The item is not returned.
55 {
56 DbgAssert( s.Count() );
57 s.Delete( s.Count()-1, 1 );
58 }

◆ GetTop()

void GetTop ( T *  el)
inline
Remarks
Retrieves the item on top of the stack without altering the stack.
Parameters:
T *el

The top item is returned here.
65 {
66 DbgAssert( s.Count() );
67 *el = s[s.Count()-1];
68 }

◆ Clear()

void Clear ( )
inline
Remarks
Clears the stack. All items are deleted.
71 {
72 s.Delete(0,s.Count());
73 }

◆ Count()

int Count ( ) const
inline
Remarks
Returns the number of item currently on the stack.
76 {
77 return s.Count();
78 }

◆ Remove()

int Remove ( int  i)
inline
Remarks
Removes the 'i-th' item from the stack.
Parameters:
int i

The item to remove from the stack.
Returns
Returns the number of items left in the stack.
85 {
86 assert(i<s.Count());
87 return s.Delete(s.Count()-1-i,1);
88 }
#define assert(expr)
Definition: assert1.h:82