GLG Toolkit, C / C++ API Library  Version 4.6
Simple Array Functions

This group contains Simple Array functions that allow to use a dynamic array functionality without the Intermediate and Extended APIs. More...

Detailed Description

This group contains Simple Array functions that allow to use a dynamic array functionality without the Intermediate and Extended APIs.

Simple Array

A Simple Array is a GLG dynamic array object that can be used to hold a variable number of elements, but, unlike a Container, cannot be added to the drawing to draw its elements.

The Simple Array functions have the same functionality as the corresponding Container Functions of the Intermediate and Extended APIs, but can be used when only the Standard API is available.

These functions work only with with a Simple Arraycreated by GlgArrayCreate and can't be used to add or delete objects from the drawing. The Simple Array functions can't be used in place of the corresponding Container Functions of the Intermediate and Extended APIs for accessing GLG Container objects.


Functions

GlgBoolean GlgArrayAddAt (GlgObject object, GlgAnyType elem, GlgLong add_index)
 Insert an element at the specified position in the Simple Array. More...
 
GlgBoolean GlgArrayAddToBottom (GlgObject object, GlgAnyType elem)
 Add an element at the end of the Simple Array. More...
 
GlgBoolean GlgArrayAddToTop (GlgObject object, GlgAnyType elem)
 Add an element at the beginning of the Simple Array. More...
 
GlgObject GlgArrayCreate (GlgLong init_size, GlgLong increment)
 Creates a Simple Array object. More...
 
GlgBoolean GlgArrayDeleteAt (GlgObject object, GlgLong delete_index)
 Deletes an element at the specified position in the Simple Array. More...
 
GlgBoolean GlgArrayDeleteFirst (GlgObject object)
 Deletes the first element of the Simple Array. More...
 
GlgBoolean GlgArrayDeleteLast (GlgObject object)
 Deletes the last element of the Simple Array. More...
 
void GlgArrayFlush (GlgObject object, GlgLong size)
 Set the size of a Simple Array. More...
 
GlgAnyType GlgArrayGetElement (GlgObject object, GlgLong index)
 Returns the element at the specified position in a Simple Array. More...
 
GlgLong GlgArrayGetIndex (GlgObject object, GlgAnyType elem)
 Returns the index of the first occurrence of an element in the Simple Array. More...
 
GlgLong GlgArrayGetSize (GlgObject object)
 Queries the size of a Simple Array. More...
 
GlgBoolean GlgArraySetElement (GlgObject object, GlgLong elem_index, GlgAnyType elem)
 Sets the value of an element at the specified position in a Simple Array. More...
 

Function Documentation

◆ GlgArrayAddAt()

GlgBoolean GlgArrayAddAt ( GlgObject  object,
GlgAnyType  elem,
GlgLong  add_index 
)

Insert an element at the specified position in the Simple Array.

Parameters
objectSimple Array object.
elemThe element to add.
add_indexThe position at which the new element will be inserted.
Returns
Success or failure status. If the specified index is invalid, an error message is generated and False is returned.

All elements at and below the insertion point will be shifted down inside the array.

◆ GlgArrayAddToBottom()

GlgBoolean GlgArrayAddToBottom ( GlgObject  object,
GlgAnyType  elem 
)

Add an element at the end of the Simple Array.

Parameters
objectSimple Array object.
elemThe element to add.
Returns
Success or failure status.

◆ GlgArrayAddToTop()

GlgBoolean GlgArrayAddToTop ( GlgObject  object,
GlgAnyType  elem 
)

Add an element at the beginning of the Simple Array.

Parameters
objectSimple Array object.
elemThe element to add.
Returns
Success or failure status.

◆ GlgArrayCreate()

GlgObject GlgArrayCreate ( GlgLong  init_size,
GlgLong  increment 
)

Creates a Simple Array object.

Parameters
init_sizeInitial size of the dynamic array. A default size is used if the parameter value is 0.
incrementSize increment used to increase the size of the array. A default increment is used if the parameter value is 0.
Returns
A dynamic array of the initial size, with all elements initialized with zeros.

The created dynamic array has elements of GlgAnyType that can hold either GlgLong elements or pointers. The array is created with the initial size specified by the initial_size parameter. When new elements are added to the array, it will increase its size using the specified size increment.

◆ GlgArrayDeleteAt()

GlgBoolean GlgArrayDeleteAt ( GlgObject  object,
GlgLong  delete_index 
)

Deletes an element at the specified position in the Simple Array.

Parameters
objectSimple Array object.
delete_indexThe index of the element to delete.
Returns
Success or failure status. If the specified index is invalid, an error message is generated and False is returned.

All elements below the deleted element will be shifted up inside the array.

◆ GlgArrayDeleteFirst()

GlgBoolean GlgArrayDeleteFirst ( GlgObject  object)

Deletes the first element of the Simple Array.

Parameters
objectSimple Array object.
Returns
Success or failure status.

All remaining array elements will be shifted up inside the array.

◆ GlgArrayDeleteLast()

GlgBoolean GlgArrayDeleteLast ( GlgObject  object)

Deletes the last element of the Simple Array.

Parameters
objectSimple Array object.
Returns
Success or failure status.

◆ GlgArrayFlush()

void GlgArrayFlush ( GlgObject  object,
GlgLong  size 
)

Set the size of a Simple Array.

Parameters
objectSimple Array object.
sizeThe new size.

This function sets the array size to the requested size. If the new size is less than the current array size, extra elements are removed. If the new size is greater than the current size, the function adds elements by making a copy of the last element in the array.

It is the responsibility of an application to free any associated memory (if any) when elements are deleted from the array.

◆ GlgArrayGetElement()

GlgAnyType GlgArrayGetElement ( GlgObject  object,
GlgLong  index 
)

Returns the element at the specified position in a Simple Array.

Parameters
objectSimple Array object.
indexElement position inside the array.
Returns
The element at the specified index.

If the specified index is invalid, an error message is generated and NULL is returned.

◆ GlgArrayGetIndex()

GlgLong GlgArrayGetIndex ( GlgObject  object,
GlgAnyType  elem 
)

Returns the index of the first occurrence of an element in the Simple Array.

Parameters
objectSimple Array object.
elemThe element to search for.
Returns
Index of the element, or -1 if not found.

◆ GlgArrayGetSize()

GlgLong GlgArrayGetSize ( GlgObject  object)

Queries the size of a Simple Array.

Parameters
objectSimple Array object.
Returns
Array size.

◆ GlgArraySetElement()

GlgBoolean GlgArraySetElement ( GlgObject  object,
GlgLong  elem_index,
GlgAnyType  elem 
)

Sets the value of an element at the specified position in a Simple Array.

Parameters
objectSimple Array object.
elem_indexThe index of the array element whose value to set.
elemThe new element value.
Returns
Success or failure status. If the specified index is invalid, an error message is generated and False is returned.