SPVM::ByteList - Continuous dynamic byte array
use SPVM::ByteList; # Create a byte list my $byte_list = SPVM::ByteList->new; # Create a byte list with array my $byte_list = SPVM::ByteList->newa([(byte)1, 2, 3]); # Get list length my $length = $byte_list->length; # Push byte value $byte_list->push((byte)3); # Pop byte value. my $byte_value = $byte_list->pop; # Unshift byte value. $byte_list->unshift((byte)3); # Shift byte value. my $byte_value = $byte_list->shift; # Set byte value. $byte_list->set(2, (byte)3); # Get byte value. my $byte_value = $byte_list->get(2); # Insert byte value $byte_list->insert(1, 3); # Remove byte value my $byte_value = $byte_list->remove(1); # Convert SPVM::ByteList to byte array. my $byte_array = $byte_list->to_array;
SPVM::ByteList is continuous dynamic byte array.
sub new : SPVM::ByteList ()
Create a new SPVM::ByteList object.
sub newa : SPVM::ByteList ($array : byte[])
Create a new SPVM::ByteList object with specific byte array.
byte
sub length : int ()
Get list length.
sub push : void ($self : self, $value : byte)
Appending the value to the end of list.
sub pop : byte ($self : self)
Pops and returns the last value of the list, shortening the array by one element If there are no elements in the list, exception occur.
sub unshift : void ($self : self, $value : byte)
Appending the value to the top of list.
sub shift : byte ($self : self)
Shifts the first value of the list off and returns it, shortening the array by 1 and moving everything down. If there are no elements in the list, exception occur.
sub set : void ($self : self, $index : int, $value : byte)
Set the value with index.
sub get : byte ($self : self, $index : int)
Get the value with index.
sub insert : void ($self : self, $index : int, $value : byte)
Insert a element to the specific index.
sub remove : byte ($self : self, $index : int)
Remove and return the element which is specified by the index.
sub to_array : byte[] ($self : self)
Convert SPVM::ByteList to byte array.
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.