Manpage logo

SPVM::Immutable::ByteList - Immutable byte Array

Name  Description  Usage  Fields  length  Class Methods  new  new_len  Instance Methods  get  to_array  Copyright & License 

Name

SPVM::Immutable::ByteList − Immutable byte Array

Description

The Immutable::ByteList has methods to manipulate an immutable byte array.

Usage

use Immutable::ByteList;
# Create a byte list
my $list = Immutable::ByteList−>new;
my $list = Immutable::ByteList−>new([(byte)1, 2, 3]);
# Create a byte list with array length
my $list = Immutable::ByteList−>new_len(10);
# Get list length
my $length = $list−>length;
# Get value.
my $element = $list−>get(2);
# Convert list to array.
my $array = $list−>to_array;

Fields

length

has length : ro int;

Gets the "length" field.

This field is the length of the elements of the list.

Class Methods

new

"static method new : Immutable::ByteList ($array : byte[] = undef);"

Creates a new Immutable::ByteList object using "new_len".

The passed length to "new_len" is the length of $array. If the array is undef, the length is 0.

The elements of $array are copied to the elements of the the created array.

Examples:

my $list = Immutable::ByteList−>new;
my $list = Immutable::ByteList−>new([(byte)1, 2, 3]);

new_len

"static method new_len : Immutable::ByteList ($length : int);"

Creates a new Immutable::ByteList object with $length.

Exceptions:

$length must be greater than or equal to 0. Otherwise an exception is thrown.

Instance Methods

get

"method get : int ($index : int);"

Gets the element of the position of $index.

If $index is a netative value, $index is set to "length" plus $index.

Exceptions:

$index must be greater than or equal to 0. Otherwise an exception is thrown.

$index must be less than the length of $list. Otherwise an exception is thrown.

to_array

"method to_array : byte[] ();"

Converts the list to an array.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License


Updated 2026-06-01 - jenkler.se | uex.se