Collections

3ds Max uses a template class called Tab (short for table) as a general purpose collection class.

Tab is a type-safe variable length array class which also supports list-like operations of insertion, appending and deleting. When using Tab note that the Tab<>:: Delete() method does not resize the storage: instead callTab<>::Shrink().

If you are going to do a sequence of calls to Tab<>::Append(), its more efficient to first call Tab<>::Resize() to make room for them.

Beware when using the Tab<>::Addr() function that it returns a pointer which may be invalid after subsequent Tab<>::Insert(),Tab<>::Append(),Tab<>::Delete(),Tab<>::Resize(), or Tab<>::Shrink() operations.

Using Tab<>::SetCount() implicitly calls Tab<>::Resize().

The Tab<> template is not meant to support more than 2 billion items (specifically 2 147 483 648); if you need to have more items, consider using an STL container which does not have the 2 billion barrier and is most likely more optimized than this version.

The implementation minimizes the storage of empty tables: they are represented by a single NULL pointer. Also, the major part of the code is generic, shared by different Tabs for different types of items.

Important Note

Do not use Tab<> with objects that have non-trivial constructors, copy constructors, or destructors. This is because Tab<> does not call constructors and destructors for items in the table, nor will it call the copy operator. So Tab<BitArray> and Tab<MSTR> are not acceptable, but Tab<BitArray*> or Tab<Float> is okay.