Foxit PDF SDK

Public Types | Public Member Functions | List of all members
CFX_ArrayTemplate< TYPE > Class Template Reference
FXCRT
Inheritance diagram for CFX_ArrayTemplate< TYPE >:

## Public Types
enum | ErrorType { invalidArraySize, memoryAllocationError, indexOutOfRange }
| Enumeration for error type. More...

## Public Member Functions
| CFX_ArrayTemplate (const CFX_ArrayTemplate &other, IFX_Allocator *pAllocator=0)
| The copy constructor. More...
| CFX_ArrayTemplate (IFX_Allocator *pAllocator=0)
| Constructor, from an allocator. More...
FX_BOOL | Add (TYPE newElement)
| Add an element at the tail. Potentially growing the array. More...
TYPE * | AddSpace ()
| Add an element's space. More...
FX_BOOL | Append (const CFX_ArrayTemplate &src)
| Append an array. More...
FX_BOOL | Copy (const CFX_ArrayTemplate &src)
| Copy from an array. More...
TYPE & | ElementAt (int nIndex)
| This method retrieves a ref to an element specified by an index number. More...
int | Find (const TYPE &data, int iStart=0) const
| Find an element from specified position to last. More...
void | FX_Error (ErrorType error, FX_INT32 badIndex=0) const
| The function is called when raise a fatal error.Print error info an exit(1). More...
const TYPE | GetAt (int nIndex) const
| This method retrieves an element specified by an index number. More...
TYPE * | GetData ()
| Direct Access to the element data (may return NULL). More...
const TYPE * | GetData () const
| Direct Access to the element data (may return NULL). More...
TYPE * | GetDataPtr (int index)
| Get a pointer to the specified element in the array. Direct pointer access. More...
int | GetSize () const
| Get the number of elements in the array. More...
int | GetUpperBound () const
| Get the upper bound in the array, actually the maximum valid index. More...
FX_BOOL | InsertAt (int nIndex, TYPE newElement, int nCount=1)
| Inset one or more continuous element at specified position. More...
FX_BOOL | InsertAt (int nStartIndex, const CFX_BasicArray *pNewArray)
| Inset an array at specified position. More...
TYPE * | InsertSpaceAt (int nIndex, int nCount)
| Insert a number of elements. More...
CFX_ArrayTemplate & | operator= (const CFX_ArrayTemplate &src)
| Assignment operator overload. More...
TYPE & | operator[] (int nIndex)
| Subscript([]) operator overload. This function returns a reference to the specified element specified by the zero-based index in nIndex. More...
const TYPE | operator[] (int nIndex) const
| Subscript([]) operator overload. It retrieves a element specified by the zero-based index in nIndex. More...
void | RemoveAll ()
| Clean up the array. More...
FX_BOOL | RemoveAt (int nIndex, int nCount=1)
| Remove a number of elements at specified position. More...
FX_BOOL | SetAt (int nIndex, TYPE newElement)
| This method overwrites an element specified by an index number. More...
FX_BOOL | SetAtGrow (int nIndex, TYPE newElement)
| Set an element value at specified position. Potentially growing the array. More...
FX_BOOL | SetSize (int nNewSize, int nGrowBy=-1)
| Change the allocated size and the grow amount. More...

## Additional Inherited Members
Public Attributes inherited from CFX_BasicArray
IFX_Allocator * | m_pAllocator
| Special allocator pointer. NULL to use default allocator.

## Detailed Description

### template<class TYPE>
class CFX_ArrayTemplate< TYPE >

The class represents array template. Total allocated size is limited to 2^28 bytes (256MB).

## Member Enumeration Documentation

## ◆ ErrorType

template<class TYPE>

enum CFX_ArrayTemplate::ErrorType

Enumeration for error type.

Values of this enumeration should be used alone.

Enumerator
invalidArraySize | Invalid array size.
memoryAllocationError | Memory allocation error.
indexOutOfRange | Index out of range.

## Constructor & Destructor Documentation

## ◆ CFX_ArrayTemplate() [1/2]

template<class TYPE>

CFX_ArrayTemplate< TYPE >::CFX_ArrayTemplate | ( | IFX_Allocator * | pAllocator = `0` | ) |
| inline

Constructor, from an allocator.

Parameters

  [in] | pAllocator | An allocator. Default value: NULL.

## ◆ CFX_ArrayTemplate() [2/2]

template<class TYPE>

CFX_ArrayTemplate< TYPE >::CFX_ArrayTemplate | ( | const CFX_ArrayTemplate< TYPE > & | other,
|  | IFX_Allocator * | pAllocator = `0`
| ) |  |
| inline

The copy constructor.

Parameters

  [in] | other | The other array template object.
  [in] | pAllocator | An allocator. Default value: NULL.

## Member Function Documentation

## ◆ Add()

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::Add | ( | TYPE | newElement | ) |
| inline

Add an element at the tail. Potentially growing the array.

Parameters

  [in] | newElement | The input element.

Returns
  true means success, while false means failure (such as memory error).

## ◆ AddSpace()

template<class TYPE>

TYPE* CFX_ArrayTemplate< TYPE >::AddSpace | ( |  | ) |
| inline

Add an element's space.

Returns
  A pointer to the added space for the new element.

## ◆ Append()

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::Append | ( | const CFX_ArrayTemplate< TYPE > & | src | ) |
| inline

Append an array.

Parameters

  [in] | src | The input array.

Returns
  TRUE means success, while FALSE means failure (such as memory error).

## ◆ Copy()

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::Copy | ( | const CFX_ArrayTemplate< TYPE > & | src | ) |
| inline

Copy from an array.

Parameters

  [in] | src | The input array.

Returns
  true means success, while false means failure (such as memory error).

## ◆ ElementAt()

template<class TYPE>

TYPE& CFX_ArrayTemplate< TYPE >::ElementAt | ( | int | nIndex | ) |
| inline

This method retrieves a ref to an element specified by an index number.

Parameters

  [in] | nIndex | Specifies the zero-based index of the element.

Returns
  A reference to the specified element.

## ◆ Find()

template<class TYPE>

int CFX_ArrayTemplate< TYPE >::Find | ( | const TYPE & | data,
|  | int | iStart = `0`
| ) |  | const
| inline

Find an element from specified position to last.

Parameters

  [in] | data | The input element.
  [in] | iStart | Specifies the zero-based index of start element to find.

Returns
  An index of the found element. -1 means found none.

## ◆ FX_Error()

template<class TYPE>

void CFX_ArrayTemplate< TYPE >::FX_Error | ( | ErrorType | error,
|  | FX_INT32 | badIndex = `0`
| ) |  | const
| inline

The function is called when raise a fatal error.Print error info an exit(1).

Parameters

  [in] | error | The error type. It should be one of following values: CFX_ArrayTemplate::invalidArraySize, CFX_ArrayTemplate::memoryAllocationError.
  [in] | badIndex | The bad index. Default value: 0

Returns
  None.

## ◆ GetAt()

template<class TYPE>

const TYPE CFX_ArrayTemplate< TYPE >::GetAt | ( | int | nIndex | ) | const
| inline

This method retrieves an element specified by an index number.

Parameters

  [in] | nIndex | Specifies the zero-based index of the element.

Returns
  An element.

## ◆ GetData() [1/2]

template<class TYPE>

TYPE* CFX_ArrayTemplate< TYPE >::GetData | ( |  | ) |
| inline

Direct Access to the element data (may return NULL).

Returns
  An element type pointer.

## ◆ GetData() [2/2]

template<class TYPE>

const TYPE* CFX_ArrayTemplate< TYPE >::GetData | ( |  | ) | const
| inline

Direct Access to the element data (may return NULL).

Returns
  A constant element type pointer.

## ◆ GetDataPtr()

template<class TYPE>

TYPE* CFX_ArrayTemplate< TYPE >::GetDataPtr | ( | int | index | ) |
| inline

Get a pointer to the specified element in the array. Direct pointer access.

Parameters

  [in] | index | Specifies the zero-based index of element in the array.

Returns
  A pointer to the specified element.

## ◆ GetSize()

template<class TYPE>

int CFX_ArrayTemplate< TYPE >::GetSize | ( |  | ) | const
| inline

Get the number of elements in the array.

Returns
  The number of elements in the array.

## ◆ GetUpperBound()

template<class TYPE>

int CFX_ArrayTemplate< TYPE >::GetUpperBound | ( |  | ) | const
| inline

Get the upper bound in the array, actually the maximum valid index.

Returns
  The upper bound.

## ◆ InsertAt() [1/2]

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::InsertAt | ( | int | nIndex,
|  | TYPE | newElement,
|  | int | nCount = `1`
| ) |  |
| inline

Inset one or more continuous element at specified position.

Parameters

  [in] | nIndex | Specifies the zero-based index in the array.
  [in] | newElement | Specifies the element value to insert.
  [in] | nCount | Specifies the count of the element to insert.

Returns
  TRUE means success, while FALSE means failure (such as parameter or memory error).

## ◆ InsertAt() [2/2]

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::InsertAt | ( | int | nStartIndex,
|  | const CFX_BasicArray * | pNewArray
| ) |  |
| inline

Inset an array at specified position.

Parameters

  [in] | nStartIndex | Specifies the zero-based index of start element to insert at.
  [in] | pNewArray | The input array.

Returns
  TRUE means success, while FALSE means failure (such as parameter or memory error).

## ◆ InsertSpaceAt()

template<class TYPE>

TYPE* CFX_ArrayTemplate< TYPE >::InsertSpaceAt | ( | int | nIndex,
|  | int | nCount
| ) |  |
| inline

Insert a number of elements.

Parameters

  [in] | nIndex | Specifies the zero-based index of start element in the array.
  [in] | nCount | Specifies the count of elements to insert.

Returns
  A pointer to the inserted space for the new element.

## ◆ operator=()

template<class TYPE>

CFX_ArrayTemplate& CFX_ArrayTemplate< TYPE >::operator= | ( | const CFX_ArrayTemplate< TYPE > & | src | ) |
| inline

Assignment operator overload.

Parameters

  [in] | src | The input array.

Returns
  A reference to current array object.

## ◆ operator[]() [1/2]

template<class TYPE>

TYPE& CFX_ArrayTemplate< TYPE >::operator[] | ( | int | nIndex | ) |
| inline

Subscript([]) operator overload. This function returns a reference to the specified element specified by the zero-based index in nIndex.

Parameters

  [in] | nIndex | Specifies the zero-based index in the array.

Returns
  A reference to the specified element.

## ◆ operator[]() [2/2]

template<class TYPE>

const TYPE CFX_ArrayTemplate< TYPE >::operator[] | ( | int | nIndex | ) | const
| inline

Subscript([]) operator overload. It retrieves a element specified by the zero-based index in nIndex.

Parameters

  [in] | nIndex | Specifies the zero-based index in the array.

Returns
  An element value.

## ◆ RemoveAll()

template<class TYPE>

void CFX_ArrayTemplate< TYPE >::RemoveAll | ( |  | ) |
| inline

Clean up the array.

Returns
  None.

## ◆ RemoveAt()

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::RemoveAt | ( | int | nIndex,
|  | int | nCount = `1`
| ) |  |
| inline

Remove a number of elements at specified position.

Parameters

  [in] | nIndex | Specifies the zero-based index in the array.
  [in] | nCount | Specifies the count of element to remove.

Returns
  TRUE means success, while FALSE means failure (such as parameter or memory error).

## ◆ SetAt()

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::SetAt | ( | int | nIndex,
|  | TYPE | newElement
| ) |  |
| inline

This method overwrites an element specified by an index number.

Parameters

  [in] | nIndex | Specifies the zero-based index of the element.
  [in] | newElement | An element.

Returns
  true means success, while false means failure.

## ◆ SetAtGrow()

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::SetAtGrow | ( | int | nIndex,
|  | TYPE | newElement
| ) |  |
| inline

Set an element value at specified position. Potentially growing the array.

Parameters

  [in] | nIndex | Specifies the zero-based index of element in the array.
  [in] | newElement | The input element.

Returns
  true means success, while false means failure.

## ◆ SetSize()

template<class TYPE>

FX_BOOL CFX_ArrayTemplate< TYPE >::SetSize | ( | int | nNewSize,
|  | int | nGrowBy = `-1`
| ) |  |
| inline

Change the allocated size and the grow amount.

Parameters

  [in] | nNewSize | The new size in elements expected.
  [in] | nGrowBy | The grow amount in elements expected. This can be -1 for the grow amount unchanged.

Returns
  true means success, while false means failure (such as parameter or memory error).