array
This module provides multiple classes for working with arrays of twos-complement integers in the platform byte order. The classes provided in this module complement the bytes() object and allow higher other binary data manipulation.
Fields
- array.INT16_MAX ➝ number
- Maximum value that "should" exist in a list passed to Int16Array.
- array.UINT16_MAX ➝ number
- Maximum value that "should" exist in a list passed to UInt16Array.
- array.INT32_MAX ➝ number
- Maximum value that "should" exist in a list passed to Int32Array.
- array.UINT32_MAX ➝ number
- Maximum value that "should" exist in a list passed to UInt32Array.
- array.INT64_MAX ➝ number
- Maximum value that "should" exist in a list passed to Int64Array.
- array.UINT64_MAX ➝ number
- Maximum value that "should" exist in a list passed to UInt64Array.
- array.FLOAT_MAX ➝ number
- Maximum value that "should" exist in a list passed to FloatArray.
- array.INT16_MIN ➝ number
- Minimum value that "should" exist in a list passed to Int16Array.
- array.INT32_MIN ➝ number
- Minimum value that "should" exist in a list passed to Int32Array.
- array.INT64_MIN ➝ number
- Minimum value that "should" exist in a list passed to Int64Array.
- array.FLOAT_MIN ➝ number
- Minimum value that "should" exist in a list passed to FloatArray.
Classes
- class Int16Array
-
class Int16Array represents an array of twos-complement 16-bit signed integers in the platform byte order.
@printable, @serializable, @iterable
- .Int16Array(n) ➝ Constructor
-
-
If n is a number, it creates a new Int16Array that can hold up to n number of elements, but with all the elements set to 0.
-
If n is a list, it creates a new Int16Array with its elements set to the values in the list.
-
@params:
- number|list n
-
- .length()
-
Returns the number of items in the array.
- @returns: number
- .bytes_length()
-
Returns the length of the array if it were to be converted to bytes.
- @returns: number
- .first()
-
Returns the first item in the array or nil if the array is empty.
- @returns: number
- .last()
-
Returns the last item in the array or nil if the array is empty.
- @returns: int
- .append(value)
-
Adds the given value to the end of the array.
- @params:
- int value
- @params:
- .get(index)
-
Returns the number at the specified index in the array. If index is outside the boundary of the array indexes (0..(array.length() - 1)), an exception is thrown.
- @params:
- number index
- @returns: number
- @params:
- .set(index, value)
-
Sets the value at the given index.
- @params:
- number index
- number value
- @returns: number
- @params:
- .extend(array)
-
Updates the content of the current array by appending all the contents of array to the end of the array in exact order.
- @params:
- Int16Array array
- @params:
- .reverse()
-
Returns a new array containing the elements in the original array in reverse order.
- .clone()
-
Returns a new Int16Array containing all items from the current array. The new array is a shallow copy of the original array.
- @returns: Int16Array
- .pop()
-
Removes the last element in the array and returns the value of that item.
- @returns: number
- .to_bytes()
-
Returns the array as a bytes object.
- @returns: bytes
- .to_list()
-
Returns the elements of the array as a list of numbers.
- @returns: list
- .to_string()
-
Returns a string representation of the array.
- @returns: string
- .get_pointer()
-
Returns the raw int16 array pointer.
- @returns: ptr
- class Int32Array
-
class Int32Array represents an array of twos-complement 32-bit signed integers in the platform byte order.
@printable, @serializable, @iterable
- .Int32Array(n) ➝ Constructor
-
-
If n is a number, it creates a new Int32Array that can hold up to n number of elements, but with all the elements set to 0.
-
If n is a list, it creates a new Int32Array with its elements set to the values in the list.
-
@params:
- number|list n
-
- .length()
-
Returns the number of items in the array.
- @returns: number
- .bytes_length()
-
Returns the length of the array if it were to be converted to bytes.
- @returns: number
- .first()
-
Returns the first item in the array or nil if the array is empty.
- @returns: int
- .last()
-
Returns the last item in the array or nil if the array is empty.
- @returns: int
- .append(value)
-
Adds the given value to the end of the array.
- @params:
- int value
- @params:
- .get(index)
-
Returns the number at the specified index in the array. If index is outside the boundary of the array indexes (0..(array.length() - 1)), an exception is thrown.
- @params:
- number index
- @returns: number
- @params:
- .set(index, value)
-
Sets the value at the given index.
- @params:
- number index
- int value
- @returns: number
- @params:
- .extend(array)
-
Updates the content of the current array by appending all the contents of array to the end of the array in exact order.
- @params:
- Int32Array array
- @params:
- .reverse()
-
Returns a new array containing the elements in the original array in reverse order.
- .clone()
-
Returns a new Int32Array containing all items from the current array. The new array is a shallow copy of the original array.
- @returns: Int32Array
- .pop()
-
Removes the last element in the array and returns the value of that item.
- @returns: number
- .to_bytes()
-
Returns the array as a bytes object.
- @returns: bytes
- .to_list()
-
Returns the elements of the array as a list of numbers.
- @returns: list
- .to_string()
-
Returns a string representation of the array.
- @returns: string
- .get_pointer()
-
Returns the raw int32 array pointer.
- @returns: ptr
- class Int64Array
-
class Int64Array represents an array of twos-complement 64-bit signed integers in the platform byte order.
@printable, @serializable, @iterable
- .Int64Array(n) ➝ Constructor
-
-
If n is a number, it creates a new Int64Array that can hold up to n number of elements, but with all the elements set to 0.
-
If n is a list, it creates a new Int64Array with its elements set to the values in the list.
-
@params:
- number|list n
-
- .length()
-
Returns the number of items in the array.
- @returns: number
- .bytes_length()
-
Returns the length of the array if it were to be converted to bytes.
- @returns: number
- .first()
-
Returns the first item in the array or nil if the array is empty.
- @returns: number
- .last()
-
Returns the last item in the array or nil if the array is empty.
- @returns: number
- .append(value)
-
Adds the given value to the end of the array.
- @params:
- int value
- @params:
- .get(index)
-
Returns the number at the specified index in the array. If index is outside the boundary of the array indexes (0..(array.length() - 1)), an exception is thrown.
- @params:
- number index
- @returns: number
- @params:
- .set(index, value)
-
set(index: number, value: number)
Sets the value at the given index.
- @params:
- number index
- number value
- @returns: number
- @params:
- .extend(array)
-
Updates the content of the current array by appending all the contents of array to the end of the array in exact order.
- @params:
- Int64Array array
- @params:
- .reverse()
-
Returns a new array containing the elements in the original array in reverse order.
- .clone()
-
Returns a new Int64Array containing all items from the current array. The new array is a shallow copy of the original array.
- @returns: Int64Array
- .pop()
-
Removes the last element in the array and returns the value of that item.
- @returns: number
- .to_bytes()
-
Returns the array as a bytes object.
- @returns: bytes
- .to_list()
-
Returns the elements of the array as a list of numbers.
- @returns: list
- .to_string()
-
Returns a string representation of the array.
- @returns: string
- .get_pointer()
-
Returns the raw int64 array pointer.
- @returns: ptr
- class UInt16Array
-
class UInt16Array represents an array of twos-complement 16-bit unsigned integers in the platform byte order.
@printable, @serializable, @iterable
- .UInt16Array(n) ➝ Constructor
-
-
If n is a number, it creates a new UInt16Array that can hold up to n number of elements, but with all the elements set to 0.
-
If n is a list, it creates a new UInt16Array with its elements set to the values in the list.
-
@params:
- number|list n
-
- .length()
-
Returns the number of items in the array.
- @returns: number
- .bytes_length()
-
Returns the length of the array if it were to be converted to bytes.
- @returns: number
- .first()
-
Returns the first item in the array or nil if the array is empty.
- @returns: number
- .last()
-
Returns the last item in the array or nil if the array is empty.
- @returns: number
- .append(value)
-
Adds the given value to the end of the array.
- @params:
- int value
- @params:
- .get(index)
-
Returns the number at the specified index in the array. If index is outside the boundary of the array indexes (0..(array.length() - 1)), an exception is thrown.
- @params:
- number index
- @returns: number
- @params:
- .set(index, value)
-
Sets the value at the given index.
- @params:
- number index
- number value
- @returns: number
- @params:
- .extend(array)
-
Updates the content of the current array by appending all the contents of array to the end of the array in exact order.
- @params:
- UInt16Array array
- @params:
- .reverse()
-
Returns a new array containing the elements in the original array in reverse order.
- .clone()
-
Returns a new UInt16Array containing all items from the current array. The new array is a shallow copy of the original array.
- @returns: UInt16Array
- .pop()
-
Removes the last element in the array and returns the value of that item.
- @returns: number
- .to_bytes()
-
Returns the array as a bytes object.
- @returns: bytes
- .to_list()
-
Returns the elements of the array as a list of numbers.
- @returns: list
- .to_string()
-
Returns a string representation of the array.
- @returns: string
- .get_pointer()
-
Returns the raw uint16 array pointer.
- @returns: ptr
- class UInt32Array
-
class UInt32Array represents an array of twos-complement 32-bit unsigned integers in the platform byte order.
@printable, @serializable, @iterable
- .UInt32Array(n) ➝ Constructor
-
-
If n is a number, it creates a new UInt32Array that can hold up to n number of elements, but with all the elements set to 0.
-
If n is a list, it creates a new UInt32Array with its elements set to the values in the list.
-
@params:
- number|list n
-
- .length()
-
Returns the number of items in the array.
- @returns: number
- .bytes_length()
-
Returns the length of the array if it were to be converted to bytes.
- @returns: number
- .first()
-
Returns the first item in the array or nil if the array is empty.
- @returns: number
- .last()
-
Returns the last item in the array or nil if the array is empty.
- @returns: number
- .append(value)
-
Adds the given value to the end of the array.
- @params:
- int value
- @params:
- .get(index)
-
Returns the number at the specified index in the array. If index is outside the boundary of the array indexes (0..(array.length() - 1)), an exception is thrown.
- @params:
- number index
- @returns: number
- @params:
- .set(index, value)
-
Sets the value at the given index.
- @params:
- number index
- number value
- @returns: number
- @params:
- .extend(array)
-
Updates the content of the current array by appending all the contents of array to the end of the array in exact order.
- @params:
- UInt32Array array
- @params:
- .reverse()
-
Returns a new array containing the elements in the original array in reverse order.
- .clone()
-
Returns a new UInt32Array containing all items from the current array. The new array is a shallow copy of the original array.
- @returns: UInt32Array
- .pop()
-
Removes the last element in the array and returns the value of that item.
- @returns: number
- .to_bytes()
-
Returns the array as a bytes object.
- @returns: bytes
- .to_list()
-
Returns the elements of the array as a list of numbers.
- @returns: list
- .to_string()
-
Returns a string representation of the array.
- @returns: string
- .get_pointer()
-
Returns the raw uint32 array pointer.
- @returns: ptr
- class UInt64Array
-
class UInt64Array represents an array of twos-complement 64-bit unsigned integers in the platform byte order.
@printable, @serializable, @iterable
- .UInt64Array(n) ➝ Constructor
-
-
If n is a number, it creates a new UInt64Array that can hold up to n number of elements, but with all the elements set to 0.
-
If n is a list, it creates a new UInt64Array with its elements set to the values in the list.
-
@params:
- number|list n
-
- .length()
-
Returns the number of items in the array.
- @returns: number
- .bytes_length()
-
Returns the length of the array if it were to be converted to bytes.
- @returns: number
- .first()
-
Returns the first item in the array or nil if the array is empty.
- @returns: number
- .last()
-
Returns the last item in the array or nil if the array is empty.
- @returns: number
- .append(value)
-
Adds the given value to the end of the array.
- @params:
- int value
- @params:
- .get(index)
-
Returns the number at the specified index in the array. If index is outside the boundary of the array indexes (0..(array.length() - 1)), an exception is thrown.
- @params:
- number index
- @returns: number
- @params:
- .set(index, value)
-
Sets the value at the given index.
- @params:
- number index
- number value
- @returns: number
- @params:
- .extend(array)
-
Updates the content of the current array by appending all the contents of array to the end of the array in exact order.
- @params:
- UInt64Array array
- @params:
- .reverse()
-
Returns a new array containing the elements in the original array in reverse order.
- .clone()
-
Returns a new UInt64Array containing all items from the current array. The new array is a shallow copy of the original array.
- @returns: UInt64Array
- .pop()
-
Removes the last element in the array and returns the value of that item.
- @returns: number
- .to_bytes()
-
Returns the array as a bytes object.
- @returns: bytes
- .to_list()
-
Returns the elements of the array as a list of numbers.
- @returns: list
- .to_string()
-
Returns a string representation of the array.
- @returns: string
- .get_pointer()
-
Returns the raw uint64 array pointer.
- @returns: ptr
- class FloatArray
-
class FloatArray represents an array of 32-bit floating point numbers corresponding to the C float data type in the platform byte order.
@printable, @serializable, @iterable
- .FloatArray(n) ➝ Constructor
-
-
If n is a number, it creates a new FloatArray that can hold up to n number of elements, but with all the elements set to 0.
-
If n is a list, it creates a new FloatArray with its elements set to the values in the list.
-
@params:
- number|list n
-
- .length()
-
Returns the number of items in the array.
- @returns: number
- .bytes_length()
-
Returns the length of the array if it were to be converted to bytes.
- @returns: number
- .first()
-
Returns the first item in the array or nil if the array is empty.
- @returns: number
- .last()
-
Returns the last item in the array or nil if the array is empty.
- @returns: number
- .append(value)
-
Adds the given value to the end of the array.
- @params:
- int value
- @params:
- .get(index)
-
Returns the number at the specified index in the array. If index is outside the boundary of the array indexes (0..(array.length() - 1)), an exception is thrown.
- @params:
- number index
- @returns: number
- @params:
- .set(index, value)
-
Sets the value at the given index.
- @params:
- number index
- int value
- @returns: number
- @params:
- .extend(array)
-
Updates the content of the current array by appending all the contents of array to the end of the array in exact order.
- @params:
- FloatArray array
- @params:
- .reverse()
-
Returns a new array containing the elements in the original array in reverse order.
- .clone()
-
Returns a new FloatArray containing all items from the current array. The new array is a shallow copy of the original array.
- @returns: FloatArray
- .pop()
-
Removes the last element in the array and returns the value of that item.
- @returns: number
- .to_bytes()
-
Returns the array as a bytes object
- @returns: bytes
- .to_list()
-
Returns the elements of the array as a list of numbers
- @returns: list
- .to_string()
-
Returns a string representation of the array
- @returns: string
- .get_pointer()
-
Returns the raw uint64 array pointer.
- @returns: ptr