3ds Max C++ API Reference
|
A generic array container, with proper support for non-POD types. More...
#include <Array.h>
Public Types | |
typedef int(__cdecl * | CompareFnc) (const void *elem1, const void *elem2) |
Type of function to pass to sort(). | |
Public Member Functions | |
Array () | |
Initializes an empty array. | |
Array (size_t initUsedLength, const T &defaultVal=T(), size_t initGrowLength=kDefaultGrowthLength) | |
Initializes an array with an initial size. | |
Array (const Array< T > &src) | |
Copy constructor. | |
template<class InputIt > | |
Array (InputIt begin, InputIt end) | |
Copy constructor. | |
~Array () | |
Destructor. Destroys every element stored in the array, and frees the allocated storage. | |
Array< T > & | operator= (const Array< T > &src) |
Copy operator. | |
bool | operator== (const Array< T > &op) const |
Equality operator. | |
Array< T > & | setAt (size_t index, const T &value) |
Sets a copy of value at the given index. | |
Array< T > & | setAll (const T &value) |
Sets all the elements of the array to the given value. | |
bool | isValidIndex (size_t) const |
Returns whether the given array index is valid for this array. | |
T & | operator[] (size_t i) |
Subscript operator. | |
const T & | operator[] (size_t i) const |
Subscript operator. | |
const T & | at (size_t index) const |
Same as subscript operator. | |
T & | at (size_t index) |
Same as subscript operator. | |
T & | first () |
Accesses the first element in the array. | |
const T & | first () const |
Accesses the first element in the array. | |
T * | begin () |
Accesses the begin iterator, which is a plain pointer in this case. | |
const T * | begin () const |
Accesses the const begin iterator, which is a plain pointer in this case. | |
T & | last () |
Accesses the last element in the array. | |
const T & | last () const |
Accesses the first element in the array. | |
T * | end () |
Accesses the end iterator (one past last valid element). Do not dereference. | |
const T * | end () const |
Accesses the const end iterator (one past last valid element). Do not dereference. | |
size_t | append (const T &value) |
Appends a copy of value to the array. | |
Array< T > & | append (const T *values, size_t count) |
Appends one or more element(s) to the array. | |
Array< T > & | append (const Array< T > &array) |
Appends the contents of another array to this array. | |
Array< T > & | insertAt (size_t index, const T &value) |
Inserts a single value, at a given location, into this array. | |
Array< T > & | insertAt (size_t index, const T *values, size_t count) |
Inserts a one or more value(s), at a given location, into this array. | |
Array< T > & | removeAt (size_t index) |
Removes a single element from the array. | |
bool | remove (const T &value, size_t start=0) |
Searches for a value in the array and, if it is found, removes it from the array. | |
Array< T > & | removeFirst () |
Removes the first element of the array. | |
Array< T > & | removeLast () |
Removes the last element of the array. | |
Array< T > & | removeAll () |
Removes all the elements from the array. | |
Array< T > & | removeSubArray (size_t startIndex, size_t endIndex) |
Removes a subset of the array. | |
bool | contains (const T &value, size_t start=0) const |
Determines if a value is stored in the array. | |
bool | find (const T &value, size_t &foundAt, size_t start=0) const |
Searches for a value in the array. | |
size_t | find (const T &value) const |
Searches for a value in the array. | |
size_t | findFrom (const T &value, size_t start) const |
Searches for a value in the array, starting at a given index. | |
size_t | length () const |
Returns the number of used elements (as opposed to simply allocated/reserved) in the array. | |
bool | isEmpty () const |
Returns true if the number of used elements in the array is 0; returns false otherwise. | |
size_t | lengthUsed () const |
Returns the number of elements used (as opposed to simply allocated/reserved) in the array. | |
Array< T > & | setLengthUsed (size_t length, const T &defaultVal=T()) |
Sets the number of elements used (as opposed to simply allocated/reserved) in the array. | |
size_t | lengthReserved () const |
Returns the number of elements allocated/reserved (as opposed to actually used) in the array. | |
Array< T > & | setLengthReserved (size_t length) |
Sets the number of elements allocated/reserved (as opposed to actually used) in the array. | |
void | reserve (size_t capacity) |
Alias for setLengthReserved. | |
size_t | growLength () const |
Returns the growth length of the array. | |
Array< T > & | setGrowLength (size_t) |
Sets the growth length of the array. | |
Array< T > & | reverse () |
Reverses the sequence of elements in the array. | |
Array< T > & | swap (size_t i1, size_t i2) |
Swaps two elements in this array. | |
void | sort (CompareFnc cmp) |
Sorts the elements of the array using a custom comparison function. | |
const T * | asArrayPtr () const |
Returns the array storage as a C-style array pointer. | |
T * | asArrayPtr () |
Accesses the first element in the array. | |
Protected Types | |
enum | { kDefaultGrowthLength = 8 } |
Static Protected Member Functions | |
static size_t | quickSortPartition (T *data, size_t first, size_t last, CompareFnc cmp) |
The partition portion of the QuickSort algorithm. | |
static void | quickSortRecursive (T *data, size_t first, size_t last, CompareFnc cmp) |
Recursive QuickSort function used to sort the elements of the array. | |
static void | handleOutOfMemory () |
Utility function, called when the array fails to allocate memory. | |
static T * | ArrayAllocate (size_t len) |
Allocates an array of elements without constructing them. | |
static void | ArrayConstruct (T *arrayBegin, size_t len, const T &defaultVal) |
Constructs an array of elements. | |
static void | ArrayDeAllocate (T *arrayBegin) |
De-allocates an array of elements without destructing them. | |
static void | ArrayDestruct (T *arrayBegin, size_t len) |
Destructs an array of elements. | |
static void | ArrayCopy (T *pCopy, size_t nMaxCount, const T *pSource, size_t nCount) |
Copies an array of elements to an already-constructed buffer. | |
static void | ArrayCopyOverlap (T *pCopy, size_t nMaxCount, const T *pSource, size_t nCount) |
Copies an array of elements when the target and destination memory buffers may overlap. | |
static void | ArrayCopyConstruct (T *pCopy, size_t nMaxCount, const T *pSource, size_t nCount) |
Copies and array of elements to a non-constructed. | |
Protected Attributes | |
T * | mpArray |
Pointer to the storage buffer. | |
size_t | mReservedLen |
The reserved length (in number of elements, not bytes). | |
size_t | mUsedLen |
The used length (in number of elements, not bytes). | |
size_t | mGrowLen |
The growth length. See setGrowLength(). | |
Additional Inherited Members | |
![]() | |
static UtilExport void * | operator new (size_t size) |
Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. | |
static UtilExport void * | operator 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 void * | operator 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 void * | operator 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 void * | operator 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 void * | operator 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 void * | operator 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 void * | operator new[] (size_t size) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. | |
static UtilExport void * | operator 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 void * | operator 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 void * | operator new[] (size_t size, int block_type, const char *filename, int line) |
New operator used to allocate arrays of objects. | |
static UtilExport void * | operator 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 void * | operator 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 void * | operator 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 void * | operator 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 void * | aligned_malloc (size_t size, size_t alignment) |
Allocates memory on a specified alignment boundary. | |
static UtilExport void * | aligned_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. | |
A generic array container, with proper support for non-POD types.
This template class is a generic, dynamic array container, similar to the STL class "vector". Whereas the classical 3ds Max SDK class Tab supports only POD types, this class supports non-POD types as well.
Type of function to pass to sort().
|
protected |
Enumerator | |
---|---|
kDefaultGrowthLength | The default growth length. See setGrowLength(). |
Initializes an empty array.
Array | ( | size_t | initUsedLength, |
const T & | defaultVal = T() , |
||
size_t | initGrowLength = kDefaultGrowthLength |
||
) |
Initializes an array with an initial size.
[in] | initUsedLength | - Number of elements initially allocated in the array. |
[in] | defaultVal | - The default value for the elements initially allocated. |
[in] | initGrowLength | - The initial growth length of the array. For more information on the growth length, see setGrowLength(). |
Copy constructor.
Copies the contents of another array.
[in] | src | - Array from which the elements are copied. |
Array | ( | InputIt | begin, |
InputIt | end | ||
) |
Copy constructor.
Copies the contents values between 2 iterators.
[in] | begin | - iterator that defines where to start copying from |
[in] | end | - iterator that defines when to stop copying |
Destructor. Destroys every element stored in the array, and frees the allocated storage.
Copy operator.
Copies the contents of another array.
[in] | src | - Array from which the elements are copied. |
bool operator== | ( | const Array< T > & | op | ) | const |
|
inline |
Subscript operator.
[in] | i | - Index of array element to access. This index must be within the array bounds. If the index is out of bounds it will throw a MaxSDK::Util::MaxOutOfRangeException exception. |
|
inline |
Subscript operator.
[in] | i | - Index of array element to access. This index must be within the array bounds. If the index is out of bounds it will throw a MaxSDK::Util::MaxOutOfRangeException exception. |
|
inline |
Same as subscript operator.
[in] | index | - Index of array element to access. This index must be within the array bounds. |
|
inline |
Same as subscript operator.
[in] | index | - Index of array element to access. This index must be within the array bounds. |
Sets a copy of value at the given index.
[in] | index | - The position in the array where a copy of value is placed. This index must be within the array bounds. |
[in] | value | - a reference to the original object. |
Array< T > & setAll | ( | const T & | value | ) |
|
inline |
Accesses the first element in the array.
|
inline |
Accesses the first element in the array.
T * begin |
Accesses the begin iterator, which is a plain pointer in this case.
const T * begin |
Accesses the const begin iterator, which is a plain pointer in this case.
|
inline |
Accesses the last element in the array.
|
inline |
Accesses the first element in the array.
T * end |
const T * end |
|
inline |
Appends a copy of value to the array.
[in] | value | - A reference to the original value. |
Appends the contents of another array to this array.
[in] | array | - The array from which elements are to be appended. |
Inserts a single value, at a given location, into this array.
[in] | index | - The index at which the element is to be inserted. This index must be smaller or equal to the used length of the array. |
[in] | value | - The value to be inserted. |
Inserts a one or more value(s), at a given location, into this array.
[in] | index | - The index at which the element is to be inserted. This index must be smaller or equal to the used length of the array. |
[in] | values | - A pointer to a C-style array of elements, from which the inserted elements will be copied. |
[in] | count | - The number of elements to be inserted. |
Removes a single element from the array.
[in] | index | - The index of the element to be removed. This index must be valid (within bounds). |
bool remove | ( | const T & | value, |
size_t | start = 0 |
||
) |
Searches for a value in the array and, if it is found, removes it from the array.
[in] | value | - The value to search for. |
[in] | start | - The index at which to start searching. Preceding elements are not searched. |
|
inline |
|
inline |
|
inline |
Removes all the elements from the array.
Removes a subset of the array.
[in] | startIndex | - The index of the first element to be removed. |
[in] | endIndex | - The index of the last element to be removed. |
|
inline |
Determines if a value is stored in the array.
[in] | value | - The value for which to search for. |
[in] | start | - The index at which to start searching. Preceding elements are not searched. |
Searches for a value in the array.
[in] | value | - The value to search for. |
[out] | foundAt | - The index at which the value was found. Indeterminate if the value was not found. |
[in] | start | - The index at which to start searching. Preceding elements are not searched. |
size_t find | ( | const T & | value | ) | const |
Searches for a value in the array.
[in] | value | - The value to search for. |
Searches for a value in the array, starting at a given index.
[in] | value | - The value to search for. |
[in] | start | - The index at which to start searching. |
|
inline |
Returns the number of used elements (as opposed to simply allocated/reserved) in the array.
|
inline |
Returns true if the number of used elements in the array is 0; returns false otherwise.
|
inline |
Returns the number of elements used (as opposed to simply allocated/reserved) in the array.
Sets the number of elements used (as opposed to simply allocated/reserved) in the array.
[in] | length | - The new "used length" of the array. |
[in] | defaultVal | - The default value for new elements, used only if the length of the array is increased. |
|
inline |
Returns the number of elements allocated/reserved (as opposed to actually used) in the array.
Sets the number of elements allocated/reserved (as opposed to actually used) in the array.
[in] | length | - The new "reserved length" of the array. |
Alias for setLengthReserved.
Sets the number of elements allocated/reserved (as opposed to actually used) in the array. Named to be similar to the STL containers.
[in] | capacity | - The new "reserved length" or possible capacity of the array. |
|
inline |
Returns the growth length of the array.
For more information on the growth length, see setGrowLength().
Sets the growth length of the array.
The growth length is the minimum number elements by which the reserved space is grown whenever the array runs out of reserved space.
Array< T > & reverse |
Reverses the sequence of elements in the array.
Reverses the sequence of elements in the array such that the last element becomes the first.
Swaps two elements in this array.
[in] | i1 | - The index of the first element to swap. This index must be within bounds. |
[in] | i2 | - The index of the second element to swap. This index must be within bounds. |
void sort | ( | CompareFnc | cmp | ) |
Sorts the elements of the array using a custom comparison function.
The sort if performed with the QuickSort algorithm.
[in] | cmp | - The comparison function used to order the elements. |
|
inline |
Returns the array storage as a C-style array pointer.
|
inline |
Accesses the first element in the array.
|
inline |
Returns whether the given array index is valid for this array.
|
staticprotected |
The partition portion of the QuickSort algorithm.
|
staticprotected |
Recursive QuickSort function used to sort the elements of the array.
|
inlinestaticprotected |
Utility function, called when the array fails to allocate memory.
|
inlinestaticprotected |
Allocates an array of elements without constructing them.
Constructs an array of elements.
|
inlinestaticprotected |
De-allocates an array of elements without destructing them.
Destructs an array of elements.
Copies an array of elements to an already-constructed buffer.
Will use the copy operator if needed.
|
staticprotected |
Copies an array of elements when the target and destination memory buffers may overlap.
|
staticprotected |
Copies and array of elements to a non-constructed.
Will use the copy constructor if needed.
|
protected |
Pointer to the storage buffer.
|
protected |
The reserved length (in number of elements, not bytes).
|
protected |
The used length (in number of elements, not bytes).
|
protected |
The growth length. See setGrowLength().