SPVM::BlessedObject::Array − SPVM Array
The object of "SPVM::BlessedObject::Array" class holds an SPVM array.
# Gets an
element of the array
my $elem = $blessed_object_array−>get(2);
# Sets an element of the array
$blessed_object_array−>set(2 => 5);
# Converts an SPVM array to a Perl array reference
my $elems = $blessed_object_array−>to_elems;
# Converts an SPVM array to a binary
my $binary = $blessed_object_array−>to_bin;
my $elem = $blessed_object_array−>get($index);
Returns an element of the array with the index.
$blessed_object_array−>set($index, $elem);
Sets an element of the array with the index.
If $elem cannnot be assigned to the element of the array, an exception is thrown.
my $elems = $blessed_object_array−>to_elems;
Converts an SPVM array to a Perl array reference and returns it.
my $binary = $blessed_object_array−>to_bin;
Converts an SPVM array to a binary and returns it.
This binary is unpacked by unpack <https://perldoc.perl.org/functions/unpack> function.
If the array is an object array, an excetion is thrown.
Examples:
# byte[]
my @elems = unpack 'c*', $binary;
# short[]
my @elems = unpack 's*', $binary;
# int[]
my @elems = unpack 'l*', $binary;
# long[]
my @elems = unpack 'q*', $binary;
# float[]
my @elems = unpack 'f*', $binary;
# double[]
my @elems = unpack 'd*', $binary;
my $elems = $blessed_object_array−>to_strings;
Converts an SPVM string array to a Perl array reference and returns it.
Each element calls to_string method.
my $elems = $blessed_object_array−>to_bins;
Converts an SPVM string array to Perl array reference and returns it.
Each element calls to_bin method.
Overloads the following operators.
my @elems = @$array;
This is the same as the following operation.
my @elems = @{$array−>to_elems};
Copyright (c) 2023 Yuki Kimoto
MIT License