CArray Class


The CArray class manages a 1-dimensional array of values. The class implements a traditional vector as a 1-dimensional array of (index, value) pairs. The values may be numbers, strings, or tables. The purpose of the CArray is to allow a set of values to be referenced using numeric indices like [1] or [10000].

A CArray may be sparse, meaning that there may be "holes" at indices where no value is defined. For example, you might define only one CArray member at index 10000. Being sparse, this CArray would store only that one value in memory, rather than 9999 empty indices before it. See also the CMatrix class and the CSet class.

Usage

Construction

Object = new_array()

Object = CArray:new()

Destruction

Object:delete()

Creation - Non-class Functions

This function is normally used to create a new CArray object as an alternative to the class-based new method.

new_array

Creates a new instance of a CArray object.

Construction and Destruction - Class Methods

new

Creates a new instance of the CArray class. There are 3 constructor formats.

delete

Deletes the instance of the CArray object.

Copy

Copies this CArray to a new CArray object.

Operations

Count

Returns the number of members actually initialized.

Dot

Returns the dot product with another CArray.

Empty

Empties the contents of the CArray but does not delete it.

Exists

Returns true if a member exists at the index.

Get

Returns the member value at an array index.

Init

Initializes all members to a value.

MaxIndex

Returns the maximum member index.

Remove

Removes the member at an index.

Set

Sets the member value at an index.

Related Topics

Script Classes, CMatrix , CSet


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.