CArray Class
The CArray class manages a 1-dimensional array of values. The class implements a traditional vector as a Lua table of (index, value) pairs. The values may be any supported type of thing (number, string, object) and indexing starts at 1. Values may have different types at different indices. However, some class methods such as Init and Dot, work only with values that are numbers. The purpose of the CArray is to allow a set of values to be referenced using numeric indices like [1] or [10000].
A CArray is sparse, meaning that there may be "holes" at indices where no value is defined. For example, you might define only one value at index 10000. Being sparse, this CArray requires storing only 1 value in memory, rather than 10000 elements with one defined value following 9999 zeros. See also the CMatrix class and the CSet class.
Construction |
Object = CArray:new() |
Destruction |
Object:delete() |
There are no data members.
Creates a new instance of the CArray class. There are 3 constructor formats. |
|
Deletes the instance of the CArray object. |
|
Copies this CArray to a new CArray |
Returns the number of members actually initialized. |
|
Returns the dot product with another CArray. |
|
Empties the contents of the CArray but does not delete it. |
|
Returns true if a member exists at the index. |
|
Returns the member value at an array index. |
|
Initializes all members to a value. |
|
Returns the maximum member index. |
|
Removes the member at an index. |
|
Sets the member value at an index. |