Array class

Homepage Containers

Introduction

The Array class is designed to be a storage container for a list of objects whose count is known on creation.
To use an "Array" that grows in size, as needed, use the Vector class instead.

Structure

  1. "Class values"
  2. Capacity - number of elements the array can hold
  3. Array data - an array to store the Array's elements

Array implements the List interface.

Functions

New and Destroy

Array_new(length):
Creates a new Array object with the specified length.

Array_new1(ListObject):
Creates a new Array object containing the elements of the specified List object.

Array_destroy(ArrayObject):
Destroys the Array object and frees its memory.

Miscellaneous functions

Array_clear(ArrayObject):
Destroys (and unsets) each item in the Array. Note: calling this function will not change the Array's length.

Size functions

Array_length(ArrayObject):
Returns the number of elements the Array object can hold.

Array_size(ArrayObject):
Returns the number of elements the Array object can hold (alias for Array_length).

Getters

Array_get(ArrayObject, index):
Returns the value for the object stored in the Array at the specified position.

Array_getAddress(ArrayObject, index):
Returns the address for the object stored in the Array at the specified position.

Setters

Array_set(ArrayObject, index, object = 0):
Destroys the element stored at the specified position in the Array object,and replaces it with the new object.

Array_replace(ArrayObject, index, object = 0):
Replaces the element stored at the specified position with the new object.

Search functions

Functions that start with an "S", by default, are case-sensitive. They are functionally equivalent to the respective function (the one without the "S") with true passed for the CaseSensitive parameter. They are provided for a convenient way to perform case-sensitive matching.

Functions that start with "regex" use a regular expression, instead of a value, to perform the matching. Apart from this, they are functionally equivalent to the respective function (the one without the "regex").


Array_indexOf(ArrayObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = false):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Array_SindexOf(ArrayObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = true):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Array_regexIndexOf(ArrayObject, compareRegEx, startIndex = 1, useFunction = "getValue"):
Searches for the first occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the index for this element.


Array_findObject(ArrayObject, searchObject, startIndex = 1):
Searches for the first occurrence, starting with startIndex, of the specified object, and returns the index for this element.

Array_firstUnset(ArrayObject, startIndex = 1):
Searches for the first occurrence of an unset element, and returns the index for this element.


Array_findMatch(ArrayObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = false):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Array_SfindMatch(ArrayObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = true):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Array_regexFindMatch(ArrayObject, compareRegEx, startIndex = 1, useFunction = "getValue"):
Searches for the first occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the address for this element.



Array_lastIndexOf(ArrayObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = false):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Array_SlastIndexOf(ArrayObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = true):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Array_regexLastindexOf(ArrayObject, compareRegEx, startIndex = 0, useFunction = "getValue"):
Searches for the last occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the index for this element.


Array_findLastObject(ArrayObject, searchObject, startIndex = 0):
Searches for the last occurrence, starting with startIndex, of the specified object, and returns the index for this element.

Array_lastUnset(ArrayObject, startIndex = 0):
Searches for the last occurrence of an unset element, and returns the index for this element.


Array_findLastMatch(ArrayObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = false):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Array_SfindLastMatch(ArrayObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = true):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Array_regexFindLastMatch(ArrayObject, compareRegEx, startIndex = 0, useFunction = "getValue"):
Searches for the last occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the address for this element.


Homepage  |  Containers