- Main Page
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions

# FbxArray< Type > Class Template Reference

Search for all occurrences

## Detailed Description

### template<class Type>
class FbxArray< Type >

Class for array of elements such as pointers and plain old data structures.

This class will not call constructor and destructor for elements.

Examples:

  ExportScene03/main.cxx, SwitchBinding/main.cxx, ViewScene/main.cxx, ViewScene/SceneCache.h, ViewScene/SceneContext.cxx, and ViewScene/SceneContext.h.

Definition at line 351 of file fbxarray.h.

`#include <fbxarray.h>`

Inheritance diagram for FbxArray< Type >:
[legend]

List of all members.

## Public Member Functions
| FbxArray ()
| Constructor.
| FbxArray (const FbxArray &pArrayTemplate)
| Copy constructor.
| ~FbxArray ()
| Destructor. The destructor of elements will not be called.
int | InsertAt (int pIndex, Type pItem)
| Insert a element.
Type | RemoveAt (int pIndex)
| Remove a element in the array.
Type | RemoveLast ()
| Remove the last element in the array.
bool | RemoveIt (Type pItem)
| Remove first matching element in the array.
Type & | operator[] (int pIndex) const
| Returns a reference to the element at given position in the array.
void | SetAt (int pIndex, Type pItem)
| Set the element at given position in the array.
void | SetLast (Type pItem)
| Set the value of the last element.
Type | GetAt (int pIndex) const
| Returns the value of the element at given position in the array.
Type | GetFirst () const
| Get the first element.
Type | GetLast () const
| Get the last element.
int | Find (Type pItem) const
| Find first matching element.
int | FindAfter (int pAfterIndex, Type pItem) const
| Find first matching element after given index.
int | FindBefore (int pBeforeIndex, Type pItem) const
| Find first matching pointer before given index.
int | Add (Type pItem)
| Append an element at the end of the array.
int | AddUnique (Type pItem)
| Add Element at the end of array if not present.
void | AddMultiple (FbxUInt pItemCount)
| Add multiple elements at the end of array, use SetAt or GetArray to set the value of the new elements.
void | AddArray (const FbxArray< Type > &pArray)
| Append another array at the end of this array.
void | AddArrayNoDuplicate (const FbxArray< Type > &pArray)
| Append the elements of another array at the end of this array if they are not present.
void | RemoveArray (const FbxArray< Type > &pArray)
| Remove the elements of another array from this array is they are present.
Type * | GetArray () const
| Get pointer to internal array of elements.
FbxArray< Type > & | operator= (const FbxArray< Type > &pArrayTemplate)
| Copy array of elements.
| operator Type * ()
| Cast operator.

## Constructor & Destructor Documentation

FbxArray | ( |  | ) | `[inline]`

Constructor.

Definition at line 365 of file fbxarray.h.

    : ParentClass() {}

FbxArray | ( | const FbxArray< Type > & | pArrayTemplate | ) | `[inline]`

Copy constructor.

Definition at line 368 of file fbxarray.h.

                                                 : ParentClass()
        {
            *this = pArrayTemplate;
        }

~FbxArray | ( |  | ) | `[inline]`

Destructor. The destructor of elements will not be called.

Definition at line 374 of file fbxarray.h.

    {}

## Member Function Documentation

int InsertAt | ( | int | pIndex,
|  | Type | pItem
| ) |  | `[inline]`

Search for all occurrences

Insert a element.

Parameters:

  pIndex | Position where to insert the pointer.
  pItem | Item to insert.

Returns:
  Position of the inserted pointer in the array.

Remarks:
  If the given index is out of range, the pointer is appended at the end. No error will be thrown if the index is out of bounds.

Definition at line 382 of file fbxarray.h.

        {
            return ParentClass::InsertAt( pIndex,&pItem );
        }

Type RemoveAt | ( | int | pIndex | ) | `[inline]`

Search for all occurrences

Remove a element in the array.

Parameters:

  pIndex | Position of the item to remove.

Returns:
  Removed item.

Remarks:
  No error will be thrown if the index is out of bounds.

Reimplemented from FbxArrayBase< sizeof(Type)>.

Definition at line 392 of file fbxarray.h.

        {
            Type tmpItem = GetAt(pIndex);
            ParentClass::RemoveAt( pIndex );
            return tmpItem;
        }

Type RemoveLast | ( |  | ) | `[inline]`

Search for all occurrences

Remove the last element in the array.

Returns:
  Removed item.

Remarks:
  The array should have at least one element and no error will be thrown if the array is empty.

Definition at line 403 of file fbxarray.h.

        {
            return RemoveAt(ParentClass::GetArrayCount()-1);
        }

bool RemoveIt | ( | Type | pItem | ) | `[inline]`

Search for all occurrences

Remove first matching element in the array.

Parameters:

  pItem | Item to be removed.

Returns:
  `true` if a matching pointer is found and removed, `false` otherwise.

Definition at line 412 of file fbxarray.h.

        {
            int Index = Find (pItem);
            if (Index>=0)
            {
                RemoveAt (Index);
                return true;
            }
            return false;
        }

Type& operator[] | ( | int | pIndex | ) | const `[inline]`

Returns a reference to the element at given position in the array.

Parameters:

  pIndex | Position of element in the array.

Returns:
  The element at the specified position in the array.

Remarks:
  No error will be thrown if the index is out of bounds.

Definition at line 428 of file fbxarray.h.

        {
        #if defined(_DEBUG) && !defined(FBXSDK_ENV_MAC)
            if (!ParentClass::ValidateIndex( pIndex ))
            {
                return (Type&)(ParentClass::mBaseArray[(0)*sizeof(Type)+ ParentClass::GetHeaderOffset()]);
            }
        #endif
            return (Type&)(ParentClass::mBaseArray[(pIndex)*sizeof(Type)+ ParentClass::GetHeaderOffset()]);
        }

void SetAt | ( | int | pIndex,
|  | Type | pItem
| ) |  | `[inline]`

Search for all occurrences

Set the element at given position in the array.

Parameters:

  pIndex | Position of element in the array.
  pItem | The new element.

Remarks:
  No error will be thrown if the index is out of bounds.

Definition at line 444 of file fbxarray.h.

        {
        #if defined(_DEBUG) && !defined(FBXSDK_ENV_MAC)
            if (!ParentClass::ValidateIndex( pIndex ))
            {
                return;
            }
        #endif
            GetArray()[pIndex] = pItem;
        }

void SetLast | ( | Type | pItem | ) | `[inline]`

Search for all occurrences

Set the value of the last element.

Parameters:

  pItem | The new value of the last element.

Remarks:
  The array should have at least one element and no error will be thrown if the array is empty.

Definition at line 459 of file fbxarray.h.

        {
            SetAt (ParentClass::GetArrayCount()-1, pItem);
        }

Type GetAt | ( | int | pIndex | ) | const `[inline]`

Search for all occurrences

Returns the value of the element at given position in the array.

Parameters:

  pIndex | Position of element in the array.

Returns:
  The value of the element at the specified position in the array.

Remarks:
  No error will be thrown if the index is out of bounds.

Definition at line 469 of file fbxarray.h.

        {
        #if defined(_DEBUG) && !defined(FBXSDK_ENV_MAC)
            if (!ParentClass::ValidateIndex( pIndex ))
            {
                return (Type&)(ParentClass::mBaseArray[(0)*sizeof(Type)+ ParentClass::GetHeaderOffset()]);
            }
        #endif
            return (Type&)(ParentClass::mBaseArray[(pIndex)*sizeof(Type)+ ParentClass::GetHeaderOffset()]);
        }

Type GetFirst | ( |  | ) | const `[inline]`

Search for all occurrences

Get the first element.

Returns:
  The first element.

Remarks:
  The array should have at least one element and no error will be thrown if the array is empty.

Definition at line 484 of file fbxarray.h.

        {
            FBX_ASSERT( ParentClass::GetArrayCount() >= 1 );
            return GetAt(0);
        }

Type GetLast | ( |  | ) | const `[inline]`

Search for all occurrences

Get the last element.

Returns:
  The last element.

Remarks:
  The array should have at least one element and no error will be thrown if the array is empty.

Definition at line 494 of file fbxarray.h.

        {
            FBX_ASSERT( ParentClass::GetArrayCount() >= 1 );
            return GetAt(ParentClass::GetArrayCount()-1);
        }

int Find | ( | Type | pItem | ) | const `[inline]`

Search for all occurrences

Find first matching element.

Parameters:

  pItem | The item to be compared to each of the elements.

Returns:
  Index of first matching element or -1 if there is no matching element.

Definition at line 504 of file fbxarray.h.

        {
            return FindAfter( -1, pItem );
        }

int FindAfter | ( | int | pAfterIndex,
|  | Type | pItem
| ) |  | const `[inline]`

Search for all occurrences

Find first matching element after given index.

Parameters:

  pAfterIndex | The index after which the finding begins.
  pItem | The item to be compared to each of the elements.

Returns:
  Index of first matching pointer found after given index or -1 if there is no matching pointer.

Remarks:
  The index must be within valid range and no error will be thrown if it is invalid.

Definition at line 515 of file fbxarray.h.

        {
        #ifdef _DEBUG
            if ( pAfterIndex > ParentClass::GetArrayCount() || pAfterIndex < -1 )
            {
                FBX_ASSERT_NOW ("ArrayUL : Search Begin Index out of range");
                return -1;
            }
        #endif
            int Count;
            for ( Count=pAfterIndex+1; Count<ParentClass::GetArrayCount(); Count++)
            {
                if (GetAt(Count)==pItem)
                {
                    return Count;
                }
            }
            return -1;
        }

int FindBefore | ( | int | pBeforeIndex,
|  | Type | pItem
| ) |  | const `[inline]`

Search for all occurrences

Find first matching pointer before given index.

Parameters:

  pBeforeIndex | The index before which the finding begins.
  pItem | The item to be compared to each of the elements.

Returns:
  Index of first matching pointer found before given index or -1 if there is no matching pointer.

Remarks:
  The index must be within valid range and no error will be thrown if it is invalid.

Definition at line 541 of file fbxarray.h.

        {
        #ifdef _DEBUG
            if ( pBeforeIndex > ParentClass::GetArrayCount() || pBeforeIndex <= 0 )
            {
                FBX_ASSERT_NOW ("ArrayUL : Search Begin Index out of range");
                return -1;
            }
        #endif
            int Count;
            for ( Count=pBeforeIndex-1; Count>=0; Count--)
            {
                if (GetAt(Count)==pItem)
                {
                    return Count;
                }
            }
            return -1;
        }

int Add | ( | Type | pItem | ) | `[inline]`

Search for all occurrences

Append an element at the end of the array.

Parameters:

  pItem | Value to be copied to the new element.

Returns:
  Index of appended element.

Definition at line 565 of file fbxarray.h.

        {
            return InsertAt(ParentClass::GetArrayCount(), pItem);
        }

int AddUnique | ( | Type | pItem | ) | `[inline]`

Search for all occurrences

Add Element at the end of array if not present.

Parameters:

  pItem | Value to be copied to the new element.

Returns:
  Index of appended element.

Definition at line 574 of file fbxarray.h.

        {
            int lReturnIndex = Find(pItem);
            if (lReturnIndex == -1)
            {
                lReturnIndex = Add(pItem);
            }
            return lReturnIndex;
        }

void AddMultiple | ( | FbxUInt | pItemCount | ) | `[inline]`

Search for all occurrences

Add multiple elements at the end of array, use SetAt or GetArray to set the value of the new elements.

Parameters:

  pItemCount | How many new elements you want to add.

Definition at line 587 of file fbxarray.h.

        {
            ParentClass::AddMultiple(pItemCount);
        }

void AddArray | ( | const FbxArray< Type > & | pArray | ) | `[inline]`

Search for all occurrences

Append another array at the end of this array.

Parameters:

  pArray | Another array.

Definition at line 595 of file fbxarray.h.

        {
            int lSourceIndex, lCount = pArray.GetCount();
            if( lCount == 0 ) return;
            int lDestinationIndex = ParentClass::GetCount();
            AddMultiple(lCount);
            for( lSourceIndex = 0; lSourceIndex < lCount; lSourceIndex++)
            {
                SetAt(lDestinationIndex++, pArray[lSourceIndex]);
            }
        }

void AddArrayNoDuplicate | ( | const FbxArray< Type > & | pArray | ) | `[inline]`

Search for all occurrences

Append the elements of another array at the end of this array if they are not present.

Parameters:

  pArray | Another array.

Definition at line 610 of file fbxarray.h.

        {
            int i, lCount = pArray.GetCount();
            for( i = 0; i < lCount; i++)
            {
                Type lItem = pArray[i];
                if (Find(lItem) == -1)
                {
                    Add(lItem);
                }
            }
        }

void RemoveArray | ( | const FbxArray< Type > & | pArray | ) | `[inline]`

Search for all occurrences

Remove the elements of another array from this array is they are present.

Parameters:

  pArray | Another array.

Definition at line 626 of file fbxarray.h.

        {
            int lRemoveIndex, lRemoveCount = pArray.GetCount();
            for( lRemoveIndex = 0; lRemoveIndex < lRemoveCount; lRemoveIndex++)
            {
                RemoveIt(pArray[lRemoveIndex]);
            }
        }

Type* GetArray | ( |  | ) | const `[inline]`

Search for all occurrences

Get pointer to internal array of elements.

Definition at line 636 of file fbxarray.h.

        {
            if (ParentClass::mBaseArray == NULL)
                return NULL;

            return (Type*)(ParentClass::mBaseArray+ ParentClass::GetHeaderOffset()) ;
        }

FbxArray<Type>& operator= | ( | const FbxArray< Type > & | pArrayTemplate | ) | `[inline]`

Copy array of elements.

Definition at line 645 of file fbxarray.h.

        {
            if ( this != &pArrayTemplate )
            {
                ParentClass::Clear();

                int i, lCount = pArrayTemplate.GetCount();

                for (i = 0; i < lCount; i++)
                {
                    Add(pArrayTemplate[i]);
                }
            }

            return (*this);
        }

operator Type * | ( |  | ) | `[inline]`

Cast operator.

Definition at line 663 of file fbxarray.h.

        {
            return GetArray();
        }

The documentation for this class was generated from the following file:

- fbxsdk/core/base/fbxarray.h