# CSIBCArray Class Template Reference

Simple, all-purpose chunked array used by other classes. More...

`#include <SIBCArray.h>`

List of all members.

## Public Member Functions
| CSIBCArray (const LONG in_lNbElem=0)
LONG | GetUsed () const
LONG | GetSize () const
LONG | UsedMem () const
LONG | AllocatedMem () const
LONG | Reserve (const LONG in_lNbElem)
LONG | Resize (const LONG in_lNewNbElem)
LONG | Extend (const LONG in_lNbElem)
LONG | Add (CElemType in_Elem)
LONG | InsertAt (const LONG idx, const LONG nb)
void | DeleteAt (const LONG idx, const LONG nb)
CElemType & | operator[] (const ULONG in_lIndex) const
CElemType & | operator[] (const ULONG in_lIndex)
LONG | Pack (LONG i_MaxWasted=4)
void | DisposeData (void)
int | Become (CSIBCArray< CElemType > &in_rSrcObject)
int | Copy (const CSIBCArray< CElemType > &in_rSrcObject)
CSIBCArray< CElemType > & | operator= (const CSIBCArray< CElemType > &in_rSrcObject)
CElemType * | ArrayPtr (void)
CElemType ** | ArrayPtrPtr (void)
void | Set (LONG start, LONG nb, CElemType value)

## Detailed Description

### template<class CElemType>
class CSIBCArray< CElemType >

Simple, all-purpose chunked array used by other classes.

This class is frequently used throughout the FTK and Semantic Layer. It is the desired method for using arrays.

## Constructor & Destructor Documentation

CSIBCArray | ( | const LONG | in_lNbElem = `0` | ) | `[inline]`

Constructor. Allocates `in_lNbElem` elements of storage in the new array.

Parameters:

  | in_lNbElem | Initial element storage space to allocate. (Defaults to 0).

## Member Function Documentation

LONG GetUsed | ( |  | ) | const`[inline]`

Returns the number of element storage spaces that contain valid elements.

Returns:
  LONG Number of used element storage spaces.

See also:
  CSIBCArray::GetSize

  CSIBCArray::UsedMem

LONG GetSize | ( |  | ) | const`[inline]`

Returns the number of allocated element storage spaces.

Returns:
  LONG Number of allocated element storage spaces.

See also:
  CSIBCArray::GetUsed

  CSIBCArray::AllocatedMem

LONG UsedMem | ( |  | ) | const`[inline]`

Returns the amount memory used by element storage spaces that contain valid elements.

Returns:
  LONG The amount of memory used by valid element storage (in bytes).

See also:
  CSIBCArray::GetUsed

  CSIBCArray::AllocatedMem

LONG AllocatedMem | ( |  | ) | const`[inline]`

Returns the total memory allocated by element storage spaces in the array. This does not include the size of the SIBCArray object itself.

Returns:
  LONG The amount of memory allocated by element storage spaces (in bytes).

See also:
  CSIBCArray::GetSize

  CSIBCArray::AllocatedMem

LONG Reserve | ( | const LONG | in_lNbElem | ) | `[inline]`

Marks `in_lNbElem` elements as used. If there is sufficient allocated space to reserve `in_lNbElem`, no extra element storage is allocated. Otherwise, storage space is resized to make room for exactly `in_lNbElem` storage spaces.

Parameters:

  | in_lNbElem | Number of element storage spaces to reserve.

Returns:
  LONG The number of elements used in the array.

See also:
  CSIBCArray::Resize

  CSIBCArray::Extend

  CSIBCArray::InsertAt

LONG Resize | ( | const LONG | in_lNewNbElem | ) | `[inline]`

Changes the number of cells used in the array to `in_lNewNbElem`. If there is sufficient space allocated to set `in_lNewNbElem` elements used, no space is allocated. Otherwise, twice the requested number of elements are allocated to the array, and `in_lNewNbElem` spaces are set to used. This is done so allocation occurs less frequently.

Parameters:

  | in_lNewNbElem | Number of elements to resize the array to.

Returns:
  LONG Number of used elements in the resized array.

See also:
  CSIBCArray::Reserve

  CSIBCArray::Extend

  CSIBCArray::InsertAt

LONG Extend | ( | const LONG | in_lNbElem | ) | `[inline]`

Extends the number of cells used in the array by `in_lNbElem` elements. This is equivalent to calling SIBCArray::Resize with `in_lNbElem` + SIBCArray::GetUsed().

Parameters:

  | in_lNbElem | Number of extra elements to set to used in the array.

Returns:
  LONG Number of used elements in the extended array.

See also:
  CSIBCArray::Reserve

  CSIBCArray::Resize

  CSIBCArray::InsertAt

  CSIBCArray::Add

LONG Add | ( | CElemType | in_Elem | ) | `[inline]`

Adds an element to the end of the array.

Parameters:

  | in_Elem | Element of the template declaration type to add at the end of the array.

Returns:
  LONG Number of used elements in the array, with the new element added.

See also:
  CSIBCArray::Reserve

  CSIBCArray::Resize

  CSIBCArray::Extend

  CSIBCArray::InsertAt

  CSIBCArray::operator[]

LONG InsertAt | ( | const LONG | idx,
|  | const LONG | nb |
| ) |  |  | `[inline]`

Inserts `nb` element storage spaces at the array index `idx`.

Parameters:

  | idx | Index to insert element storage spaces at.
  | nb | Number of element storage spaces to insert.

Returns:
  LONG Number of used elements in the array, after the insertion.

See also:
  CSIBCArray::Reserve

  CSIBCArray::Resize

  CSIBCArray::Extend

  CSIBCArray::DeleteAt

  CSIBCArray::Set

void DeleteAt | ( | const LONG | idx,
|  | const LONG | nb |
| ) |  |  | `[inline]`

Deletes `nb` element storage spaces at the array index `idx`.

Parameters:

  | idx | Index to begin element deletion
  | nb | Number of elements to delete.

See also:
  CSIBCArray::InsertAt

  CSIBCArray::Set

CElemType & operator[] | ( | const ULONG | in_lIndex | ) | const`[inline]`

Indexing operator. Returns a reference to the element at the index `in_lIndex`.

Parameters:

  | in_lIndex | Index of the parameter to get.

Returns:
  CElemType& Reference to the element at the index `in_lIndex`.

See also:
  CSIBCArray::Add

  CSIBCArray::Set

CElemType & operator[] | ( | const ULONG | in_lIndex | ) | `[inline]`

Indexing operator. Returns a reference to the element at the index `in_lIndex`.

Parameters:

  | in_lIndex | Index of the parameter to get.

Returns:
  CElemType& Reference to the element at the index `in_lIndex`.

See also:
  CSIBCArray::Add

  CSIBCArray::Set

LONG Pack | ( | LONG | i_MaxWasted = `4` | ) | `[inline]`

Discards element storage spaces allocated but not used in the array, if at least `i_MaxWasted` elements are unused. Note: This function should only be used after major array sizing is done.

Parameters:

  | i_MaxWasted | Number of elements required to be wasted before packing occurs (defaults to 4).

Returns:
  LONG Number of elements used in the array.

See also:
  CSIBCArray::DisposeData

void DisposeData | ( | void |  | ) | `[inline]`

Deletes all element storage spaces, and sets allocated and used element storage spaces both to zero.

See also:
  CSIBCArray::Become

int Become | ( | CSIBCArray< CElemType > & | in_rSrcObject | ) | `[inline]`

Sets this array to contain all data from the `in_rSrcObject` array, and then sets the `in_rSrcObject` to contain no elements. This destroys all data originally contained within this array.

Parameters:

  | in_rSrcObject | The object to take data from.

Returns:
  int Always returns zero.

See also:
  CSIBCArray::Copy

int Copy | ( | const CSIBCArray< CElemType > & | in_rSrcObject | ) | `[inline]`

Allocates memory in which to store as many (or more) elements contained in `in_rSrcObject`, and copies the data from `in_rSrcObject` into this array. This destroy all data originally stored within this array.

Parameters:

  | in_rSrcObject | The array source to copy data from.

Returns:
  int Returns the number of elements used.

See also:
  CSIBCArray::operator=

CSIBCArray< CElemType > & operator= | ( | const CSIBCArray< CElemType > & | in_rSrcObject | ) | `[inline]`

Sets this array to contain the same information as `in_rSrcObject`. The functionality is equivalent to SIBCArray::Copy.

Parameters:

  | in_rSrcObject | Array object to copy data from.

Returns:
  SIBCArray<CElemType>& Reference to this array.

See also:
  CSIBCArray::Copy

CElemType* ArrayPtr | ( | void |  | ) | `[inline]`

Returns the array used internally by this object.

Returns:
  CElemType* Pointer to the first element in the internal array used by this object.

CElemType* * ArrayPtrPtr | ( | void |  | ) | `[inline]`

Returns a pointer to the array used internally by this object.

Returns:
  CElemType** Pointer to a pointer to the first element in the internal array used by this object.

void Set | ( | LONG | start,
|  | LONG | nb,
|  | CElemType | value |
| ) |  |  | `[inline]`

Sets a given number of elements, `nb`, starting at index `start` to the element given by `value`.

Parameters:

  | start | The index to start the modification of elements.
  | nb | Number of elements to set the value of.
  | value | The value to set the elements to.

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

- SIBCArray.h