++ed by:
AZJADFTRE KES XYF BEROV MHOWARD

13 PAUSE users
5 non-PAUSE users.

Yuki Kimoto

NAME

SPVM::ByteList - Continuous dynamic byte array

SYNOPSYS

  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;

DESCRIPTION

SPVM::ByteList is continuous dynamic byte array.

CLASS METHODS

new

    sub new : SPVM::ByteList ()

Create a new SPVM::ByteList object.

newa

    sub newa : SPVM::ByteList ($array : byte[])

Create a new SPVM::ByteList object with specific byte array.

INSTANCE METHODS

length

  sub length : int ()

Get list length.

push

  sub push : void ($self : self, $value : byte)

Appending the value to the end of list.

pop

  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.

unshift

  sub unshift : void ($self : self, $value : byte)

Appending the value to the top of list.

shift

  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.

set

  sub set : void ($self : self, $index : int, $value : byte)

Set the value with index.

get

  sub get : byte ($self : self, $index : int)

Get the value with index.

insert

  sub insert : void ($self : self, $index : int, $value : byte)

Insert a element to the specific index.

remove

  sub remove : byte ($self : self, $index : int)

Remove and return the element which is specified by the index.

to_array

  sub to_array : byte[] ($self : self)

Convert SPVM::ByteList to byte array.