OMStaticArray class

The OMStaticArray class contains basic library functions that enable you to create and manipulate OMStaticArray objects. An OMStaticArray is a type-safe, fixed-size array.

This class is defined in the header file omstatic.h.

Attribute summary
count - specifies the number of elements in the static array
\
theLink - specifies the link to an element in the static array
size - specifies the amount of memory allocated for the static array
Construction summary
OMStaticArray
Constructs an OMStaticArray object
~OMStaticArray
Destroys the OMStaticArray object
Method summary
operator []
Returns the element at the specified position
add - adds the specified element to the array
find
Looks for the specified element in the array
getAt
Returns the element found at the specified index
getCount
Determines how many elements are in the array
getSize
Returns the amount of memory allocated for the array
isEmpty
Determines whether the array is empty
removeAll
Deletes all the elements from the array
setAt
Inserts the specified element at the given index in the array
Attributes

count

This attribute specifies the number of elements in the static array. It is defined as follows:

int count;

theLink

This attribute specifies the link to an element in the static array. It is defined as follows:

void** theLink;

size

This attribute specifies the amount of memory allocated for the static array. It is defined as follows:

int size;
Example

To use a static array, the multiplicity must be bounded (for example, MAX_OBSERVERS).

Consider the following example:

Observer* itsObserver[MAX_OBSERVERS];
for (int iter=0; iter<MAX_OBSERVERS; iter++) 
{
    if (itsObserver[iter] != NULL)
    itsObserver[iter]->notify();
}

Feedback