@include <TypedArray>

The TypedArray class provides an array implementation which enforces type restrictions on its elements. After setting the array’s type, all elements must be pointers to objects of that type or its subclasses.

Methods

@TypedArray.set_type

Scope: public

Sets the type of elements that this array will hold. This method must be called before adding elements to the array. The array’s type cannot be changed after elements have been added.

Usage: @TypedArray.set_type $type

Parameters

  • type
    • Type: primitive
    • The type to enforce for the elements of this array.

@TypedArray.push

Scope: public

Adds a value to the end of the array, enforcing the specified type.

Usage: @TypedArray.push $value

Parameters

  • value
    • Type: primitive
    • The value to add to the array.

@TypedArray.insert

Scope: public

Inserts a value at a specific index in the array, enforcing the specified type.

Usage: @TypedArray.insert $index $value

Parameters

  • index
    • Type: primitive
    • The index at which to insert the value.
  • value
    • Type: primitive
    • The value to insert into the array.

@TypedArray.size

Scope: public

Echoes the number of elements in the array.

Usage: @TypedArray.size

@TypedArray.pop

Scope: public

Removes and echoes the last element of the array.

Usage: @TypedArray.pop

@TypedArray.remove

Scope: public

Removes the specified index from the array.

Usage: @TypedArray.remove $index

Parameters

  • index
    • Type: primitive
    • The index of the value to remove.

@TypedArray.at

Scope: public

Gets the value at a specific index.

Usage: @TypedArray.at $index

Parameters

  • index
    • Type: primitive
    • The index of the value to retrieve.

@TypedArray.front

Scope: public

Echoes the first element of the array.

Usage: @TypedArray.front

@TypedArray.back

Scope: public

Echoes the last element of the array.

Usage: @TypedArray.back

@TypedArray.all

Scope: public

Echoes all elements of the array.

Usage: @TypedArray.all

@TypedArray.empty

Scope: public

Echoes “true” if the array is empty, “false” otherwise.

Usage: @TypedArray.empty

@TypedArray.slice

Scope: public

Returns a slice of the array from start to end indices.

Usage: @TypedArray.slice $start $end

Parameters

  • start
    • Type: primitive
    • The starting index of the slice (inclusive).
  • end
    • Type: primitive
    • The ending index of the slice (inclusive).

@TypedArray.clear

Scope: public

Removes all elements from the array.

Usage: @TypedArray.clear