TypedArray
Class: TypedArray
@include <TypedArray>
Array which enforces type restrictions on its elements
The type must be set before adding any elements to the array. Once elements have been added, the type cannot be changed.
Methods
@TypedArray.set_type
Scope: public
Set 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.
Returns: 1 if the type cannot be changed, 0 otherwise.
Usage: @TypedArray.set_type $type
Parameters
type- Type:
Primitive - The type to enforce for the elements of this array.
- Type:
@TypedArray.push
Scope: public
Add a value to the end of the array, enforcing the specified type.
Returns: 1 if the value is of the wrong type, 0 otherwise.
Usage: @TypedArray.push $value
Parameters
value- Type:
Primitive - The value to add to the array.
- Type:
@TypedArray.insert
Scope: public
Insert a value at a specific index in the array, enforcing the specified type.
Returns: 1 if the value is of the wrong type or index is out of bounds, 0 otherwise.
Usage: @TypedArray.insert $index $value
Parameters
index- Type:
Primitive - The index at which to insert the value.
- Type:
value- Type:
Primitive - The value to insert into the array.
- Type:
@TypedArray.size
Scope: public
Get the number of elements in the array.
Outputs: The number of elements in the array.
Usage: @TypedArray.size
@TypedArray.pop
Scope: public
Remove and echo the last element of the array.
Returns: 1 if the array is empty, 0 otherwise.
Outputs: The last element of the array.
Usage: @TypedArray.pop
@TypedArray.remove
Scope: public
Remove the specified index from the array.
Returns: 1 if the index is out of bounds, 0 otherwise.
Usage: @TypedArray.remove $index
Parameters
index- Type:
Primitive - The index of the value to remove.
- Type:
@TypedArray.at
Scope: public
Get the value at a specific index.
Outputs: The value at the specified index.
Usage: @TypedArray.at $index
Parameters
index- Type:
Primitive - The index of the value to retrieve.
- Type:
@TypedArray.front
Scope: public
Echo the first element of the array.
Returns: 1 if the array is empty, 0 otherwise.
Outputs: The first element of the array.
Usage: @TypedArray.front
@TypedArray.back
Scope: public
Echo the last element of the array.
Returns: 1 if the array is empty, 0 otherwise.
Outputs: The last element of the array.
Usage: @TypedArray.back
@TypedArray.all
Scope: public
Echo all elements of the array.
Returns: 1 if the array is empty, 0 otherwise.
Outputs: All elements of the array separated by spaces.
Usage: @TypedArray.all
@TypedArray.empty
Scope: public
Silently returns whether the array is empty.
Returns: 0 if the array is empty, 1 otherwise.
Outputs: nothing
Usage: @TypedArray.empty
@TypedArray.slice
Scope: public
Echo a slice of the array from start to end indices.
Returns: 1 if the start index is greater than the end index or if the array is empty, 0 otherwise.
Outputs: The elements in the specified slice separated by spaces.
Usage: @TypedArray.slice $start $end
Parameters
start- Type:
Primitive - The starting index of the slice (inclusive).
- Type:
end- Type:
Primitive - The ending index of the slice (inclusive).
- Type:
@TypedArray.clear
Scope: public
Clear the array by removing all elements.
Usage: @TypedArray.clear