Next | Previous

array

This moddule 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.

Properties

  • INT16_MAXnumber:

    Maximum value that "should" exist in a list passed to Int16Array.

  • UINT16_MAXnumber:

    Maximum value that "should" exist in a list passed to UInt16Array.

  • INT32_MAXnumber:

    Maximum value that "should" exist in a list passed to Int32Array.

  • UINT32_MAXnumber:

    Maximum value that "should" exist in a list passed to UInt32Array.

  • INT64_MAXnumber:

    Maximum value that "should" exist in a list passed to Int64Array.

  • UINT64_MAXnumber:

    Maximum value that "should" exist in a list passed to UInt64Array.

  • FLOAT_MAXnumber:

    Maximum value that "should" exist in a list passed to FloatArray.

  • INT16_MINnumber:

    Minimum value that "should" exist in a list passed to Int16Array.

  • INT32_MINnumber:

    Minimum value that "should" exist in a list passed to Int32Array.

  • INT64_MINnumber:

    Minimum value that "should" exist in a list passed to Int64Array.

  • FLOAT_MINnumber:

    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.

Properties

  • @printable
  • @serializable
  • @iterable

Methods

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.
Parameters
  • 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.

Parameters
  • int value

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.

Parameters
  • number index
Returns
  • number

set(index, value)

Sets the value at the given index.

Parameters
  • number index
  • number value
Returns
  • number

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.

Parameters
  • Int16Array array

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.

Properties

  • @printable
  • @serializable
  • @iterable

Methods

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.
Parameters
  • 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.

Parameters
  • int value

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.

Parameters
  • number index
Returns
  • number

set(index, value)

Sets the value at the given index.

Parameters
  • number index
  • int value
Returns
  • number

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.

Parameters
  • Int32Array array

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.

Properties

  • @printable
  • @serializable
  • @iterable

Methods

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.
Parameters
  • 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.

Parameters
  • int value

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.

Parameters
  • number index
Returns
  • number

set(index, value)

set(index: number, value: number)

Sets the value at the given index.

Parameters
  • number index
  • number value
Returns
  • number

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.

Parameters
  • Int64Array array

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.

Properties

  • @printable
  • @serializable
  • @iterable

Methods

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.
Parameters
  • 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.

Parameters
  • int value

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.

Parameters
  • number index
Returns
  • number

set(index, value)

Sets the value at the given index.

Parameters
  • number index
  • number value
Returns
  • number

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.

Parameters
  • UInt16Array array

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.

Properties

  • @printable
  • @serializable
  • @iterable

Methods

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.
Parameters
  • 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.

Parameters
  • int value

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.

Parameters
  • number index
Returns
  • number

set(index, value)

Sets the value at the given index.

Parameters
  • number index
  • number value
Returns
  • number

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.

Parameters
  • UInt32Array array

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.

Properties

  • @printable
  • @serializable
  • @iterable

Methods

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.
Parameters
  • 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.

Parameters
  • int value

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.

Parameters
  • number index
Returns
  • number

set(index, value)

Sets the value at the given index.

Parameters
  • number index
  • number value
Returns
  • number

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.

Parameters
  • UInt64Array array

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.

Properties

  • @printable
  • @serializable
  • @iterable

Methods

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.
Parameters
  • 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.

Parameters
  • int value

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.

Parameters
  • number index
Returns
  • number

set(index, value)

Sets the value at the given index.

Parameters
  • number index
  • int value
Returns
  • number

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.

Parameters
  • FloatArray array

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