Class: Toybox.Lang.ByteArray
- Inherits:
-
Toybox.Lang.Object
Overview
ByteArray objects are fixed size, numerically indexed, single dimensional, and take Numbers with a value >= -128 and <= 255 as members.
Instance Method Summary collapse
-
add(byte as Lang.Number or Lang.Char) as Lang.ByteArray
Add a byte to the end of a ByteArray.
-
addAll(array as Lang.Array or Lang.ByteArray) as Lang.ByteArray
Add a ByteArray or an Array of bytes to the end of a ByteArray.
-
decodeNumber(format as Lang.NumberFormat, options as { :offset as Lang.Number, :endianness as Lang.Endian }) as Lang.Numeric
Decodes a portion of the array to a number based on a specified format.
-
encodeNumber(value as Lang.Numeric, format as Lang.NumberFormat, options as { :offset as Lang.Number, :endianness as Lang.Endian }) as Lang.ByteArray
Encodes a number into the byte array.
-
equals(other as Lang.Object or Null) as Lang.Boolean
Test if an Object instance is equal to another instance of an Object.
-
hashCode() as Lang.Number
Get a hash code value for a ByteArray.
-
indexOf(byte as Lang.Number or Lang.Char) as Lang.Number
Get the index of a byte within the ByteArray.
-
remove(byte as Lang.Number or Lang.Char) as Lang.Boolean
Remove a byte from a ByteArray.
-
removeAll(byte as Lang.Number or Lang.Char) as Lang.Boolean
Remove bytes from a ByteArray.
-
reverse() as Lang.ByteArray
Return a new ByteArray that contains the elements of a source ByteArray in reverse order.
-
size() as Lang.Number
Get the size of a ByteArray.
-
slice(startIndex as Lang.Number or Null, endIndex as Lang.Number or Null) as Lang.ByteArray
Get a new ByteArray containing a portion of an existing ByteArray.
-
toString() as Lang.String
Convert a ByteArray to a String.
Instance Method Details
add(byte as Lang.Number or Lang.Char) as 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.
addAll(array as Lang.Array or Lang.ByteArray) as 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.
decodeNumber(format as Lang.NumberFormat, options as { :offset as Lang.Number, :endianness as Lang.Endian }) as Lang.Numeric
Decodes a portion of the array to a number based on a specified format
encodeNumber(value as Lang.Numeric, format as Lang.NumberFormat, options as { :offset as Lang.Number, :endianness as Lang.Endian }) as Lang.ByteArray
Encodes a number into the byte array
equals(other as Lang.Object or Null) as Lang.Boolean
Test if an Object instance is equal to another instance of an Object.
hashCode() as Lang.Number
Get a hash code value for a ByteArray.
indexOf(byte as Lang.Number or Lang.Char) as Lang.Number
Get the index of a byte within the ByteArray.
remove(byte as Lang.Number or Lang.Char) as 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
.
removeAll(byte as Lang.Number or Lang.Char) as 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
.
reverse() as Lang.ByteArray
Return a new ByteArray that contains the elements of a source ByteArray in reverse order.
size() as Lang.Number
Get the size of a ByteArray.
slice(startIndex as Lang.Number or Null, endIndex as Lang.Number or Null) as Lang.ByteArray
Get a new ByteArray containing a portion of an existing ByteArray.
toString() as 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.