Class: Toybox::Lang::ByteArray

Inherits:
Object
  • Object
show all

Overview

ByteArray objects are fixed size, numerically indexed, single dimensional, and take Numbers with a value >= -128 and <= 255 as members.

Since:

  • 3.0.0

Instance Method Summary collapse

Methods inherited from Object

method, weak

Instance Method Details

add(byte) ⇒ Toybox::Lang::ByteArray

Add a byte to the end of a ByteArray.

When adding a byte, the ByteArray size is increased and new bytes are inserted at the end.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


6030
6031
# File 'Monkeybrains.rb', line 6030

def add(byte)
end

addAll(array) ⇒ Toybox::Lang::ByteArray

Add a ByteArray or an Array of bytes to the end of a ByteArray.

When adding an array of bytes, the ByteArray is expanded by the size of the provided ByteArray or Array, and all of the new elements are inserted starting at the new index.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


6046
6047
# File 'Monkeybrains.rb', line 6046

def addAll(array)
end

equals(object) ⇒ Toybox::Lang::Boolean

Test if an Object instance is equal to another instance of an Object.

Examples:

var a = [ 1, 2 ]b;
var b = [ 1, 2 ]b;
var c = [ 1, 2 ];
a.equals(b); // returns true
a.equals(c); // returns false

Parameters:

Returns:

Since:

  • 3.0.0


6173
6174
# File 'Monkeybrains.rb', line 6173

def equals(object)
end

hashCodeToybox::Lang::Number

Get a hash code value for a ByteArray.

Returns:

Since:

  • 3.0.0


6179
6180
# File 'Monkeybrains.rb', line 6179

def hashCode()
end

indexOf(byte) ⇒ Toybox::Lang::Number

Get the index of a byte within the ByteArray.

Parameters:

Returns:

  • (Toybox::Lang::Number)

    The index of the first instance of the provided byte in the ByteArray. If the byte is not found, -1 is returned.

Raises:

Since:

  • 3.0.0


6065
6066
# File 'Monkeybrains.rb', line 6065

def indexOf(byte)
end

remove(byte) ⇒ Toybox::Lang::Boolean

Remove a byte from a ByteArray.

If the passed byte is found, the ByteArray size is decreased by one and elements beyond it are shifted to the next lower index. If the ByteArray has multiple matches, the matching byte at the lowest index will be removed but the other matching bytes will not be removed.

If no byte is provided as an argument, the ByteArray will remain unchanged and remove() will return false.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


6091
6092
# File 'Monkeybrains.rb', line 6091

def remove(byte)
end

removeAll(byte) ⇒ Toybox::Lang::Boolean

Remove bytes from a ByteArray.

For each instance of the byte that is found, the ByteArray size is decreased by one and elements beyond it are shifted to the next lower index.

If no byte is given as an argument, the ByteArray will remain unchanged and removeAll() will return false.

Parameters:

Returns:

Raises:

Since:

  • 3.0.0


6116
6117
# File 'Monkeybrains.rb', line 6116

def removeAll(byte)
end

reverseToybox::Lang::ByteArray

Return a new ByteArray that contains the elements of a source ByteArray in reverse order.

Returns:

Since:

  • 3.0.0


6125
6126
# File 'Monkeybrains.rb', line 6125

def reverse()
end

sizeToybox::Lang::Number

Get the size of a ByteArray.

Returns:

Since:

  • 3.0.0


6132
6133
# File 'Monkeybrains.rb', line 6132

def size()
end

slice(startIndex, endIndex) ⇒ Toybox::Lang::ByteArray

Get a new ByteArray containing a portion of an existing ByteArray.

Parameters:

  • startIndex (Toybox::Lang::Number)

    A zero-based index of the start of the new ByteArray. If a negative startIndex is provided, it will offset from the end of the ByteArray. If the startIndex is null, the slice will begin at 0. An out-of-bounds index will be truncated to the ByteArray limits.

  • endIndex (Toybox::Lang::Number)

    A zero-based index of the end of the new ByteArray. Items are included up to, but not including endIndex. If a negative endIndex is provided, it will offset from the end of the ByteArray. If endIndex is null, the slice will end at the last element. An out-of-bounds index is truncated to the ByteArray limits.

Returns:

Since:

  • 3.0.0


6151
6152
# File 'Monkeybrains.rb', line 6151

def slice(startIndex, endIndex)
end

toStringToybox::Lang::String

Convert a ByteArray to a String.

This does not convert the elements of the ByteArray into Strings, but transforms the entire ByteArray into a String.

Returns:

Since:

  • 3.0.0


6160
6161
# File 'Monkeybrains.rb', line 6160

def toString()
end