Unicorn XML Toolkit
Version 1.50.00

Namespace Core
Class XArray

template<class TYPE> class XArray {
public:
    XArray();
    ~XArray();
public:
    int GetSize();
    void SetSize(int nSize) const;
    void RemoveAll();
    TYPE GetAt(int nIndex) const;
    void SetAt(int nIndex, const TYPE &element);
    const TYPE *GetData() const;
    TYPE *GetData();
    int Add(const TYPE &element);
    void InsertAt(int nIndex, const TYPE &element, int nCount=1);
    void RemoveAt(int nIndex, int nCount=1);
    TYPE &operator[](int nIndex);
    TYPE operator[](int nIndex) const;
    };

The template class for variable-sized arrays.

Since:
1.00.00
Version:
1.50.00
Author:
Alexey Gokhberg
Constructor/Destructor Summary
XArray ();
����������Constructs the array.
~XArray ();
����������Destroys the array.

Function Summary
int GetSize () const;
����������Returns the number of elements in this array.
void SetSize (int nSize);
����������Sets the number of elements in this array.
void RemoveAll ();
����������Removes all elements from this array.
TYPE GetAt (int nIndex) const;
����������Returns the element at the given index in this array.
void SetAt (int nIndex, const TYPE &element);
����������Sets the element at the given index in this array.
const�TYPE�* GetData () const;
����������Returns the pointer to the C++ array containing all elements of this array.
TYPE�* GetData ();
����������Returns the pointer to the C++ array containing all elements of this array.
int Add (const TYPE &element);
����������Adds the specified element to the end of this array.
void InsertAt (int nIndex, const TYPE &element, int nCount=1);
����������Inserts the specified element at the specified index into this array.
void RemoveAt (int nIndex, int nCount=1);
����������Removes elements at the specified index from this array.
TYPE�& operator[] (int nIndex);
����������Returns the reference to the element at the specified index in this array.
TYPE operator[] (int nIndex) const;
����������Returns the element at the specified index in this array.

Constructor/Destructor Detail

XArray

XArray();

Constructs the array.

The array is initially empty.

~XArray

~XArray();

Destroys the array.

Function Detail

GetSize

int GetSize() const;

Returns the number of elements in this array.

Returns:
the number of elements in this array

SetSize

void SetSize(int nSize);

Sets the number of elements in this array.

Parameters:
nSize - the new number of elements

RemoveAll

void RemoveAll();

Removes all elements from this array.

GetAt

TYPE GetAt(int nIndex) const;

Returns the element at the given index in this array.

The result is unspecified if the index is out of range.

Parameters:
nIndex - the index (zero-based)
Returns:
the element at the given index in this array

SetAt

void SetAt(int nIndex, const TYPE &element);

Sets the element at the given index in this array.

The result is unspecified if the index is out of range.

Parameters:
nIndex - the index (zero-based)
element - the new element

GetData

const TYPE *GetData() const;

Returns the pointer to the C++ array containing all elements of this array.

This pointer may become invalid after any operation that modifies content of this array.

Returns:
the pointer to the C++ array containing all elements of this array

GetData

TYPE *GetData();

Returns the pointer to the C++ array containing all elements of this array.

This pointer may become invalid after any operation that modifies content of this array.

Returns:
the pointer to the C++ array containing all elements of this array

Add

int Add(const TYPE &element);

Adds the specified element to the end of this array.

Parameters:
element - the element to add
Returns:
the index (zero-based) of the element added

InsertAt

void InsertAt(int nIndex, const TYPE &element, int nCount=1);

Inserts the specified element at the specified index into this array.

The index may be greater than the number of elements in this array.

Parameters:
nIndex - the index (zero-based)
element - the element to insert
nCount - the repetition count

RemoveAt

void RemoveAt(int nIndex, int nCount=1);

Removes elements at the specified index from this array.

The result is unspecified if the index is out of range.

Parameters:
nIndex - the index (zero-based)
nCount - the number of elements to remove

operator[]

TYPE &operator[](int nIndex);

Returns the reference to the element at the specified index in this array.

The result is unspecified if the index is out of range.

Parameters:
nIndex - the index (zero-based)
Returns:
the reference to the element at the specified index in this array

operator[]

TYPE operator[](int nIndex) const;

Returns the element at the specified index in this array.

The result is unspecified if the index is out of range.

Parameters:
nIndex - the index (zero-based)
Returns:
the element at the specified index in this array

Unicorn XML Toolkit
Version 1.50.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.