NAME

SPVM::Hash - Key-Values Stored Data Structrue

SYNOPSYS

use SPVM::Hash;

# Book Data
my $book = SPVM::Hash->new;

$book->set_int(id => 4);
$book->set(name => "Perl");
$book->set_int(price => 300);

my $id = (int)$book->get_int("id");
my $name = (string)$book->get("name");
my $price = (int)$book->get_int("price");

# Create Book data with array
my $book = SPVM::Hash->newa([(object)id => 4, name => "Perl"]);

# Option Data
my $opt = SPVM::Hash->new;
$opt->set_int(limit => 10);
$opt->set(caption => "Perl is Good Plain Old Language");
$opt->set_double(rate => 0.95);

DESCRIPTION

SPVM::Hash is Key-Values Stored Data Structrue.

STATIC METHODS

new

sub new : SPVM::Hash ()

Create a new SPVM::Hash object.

newa

sub newa : SPVM::Hash ($key_values : oarray)

Create a new SPVM::Hash object with array.

# Create Book data with object array
my $book = SPVM::Hash->newa([(object)id => 4, name => "Perl"]);

# Create Book data with string array
my $book = SPVM::Hash->newa([foo => "4px", bar => "5px"]);

INSTANCE METHODS

count

count : int ($self : self)

Count keys.

copy

copy : SPVM::Hash ($self : self)

Copy hash.

This is not deep copy. Address of keys and values is copied into new hash.

delete

delete : object ($self : self, $key : string)

Delete a key value pair. Deleted value is returned.

exists

exists : int ($self : self, $key : string)

Specify the key and check if the value exists. If exists, return 1, otherwise 0.

keys

keys : string[] ($self : self)

Get keys. This method do not copy the strings.

values

values : object[] ($self : self)

Get values.

get

get : object ($self : self, $key : string)

Get a value.

get_byte

get_byte : byte ($self : self, $name : string)

Set value with a key. the value is converted to byte type.

get_short

get_short : short ($self : self, $name : string)

Set value with a key. the value is converted to short type.

get_int

get_int : int ($self : self, $name : string)

Set value with a key. the value is converted to int type.

get_long

get_long : long ($self : self, $name : string)

Set value with a key. the value is converted to long type.

get_float

get_float : float ($self : self, $name : string)

Set value with a key. the value is converted to float type.

get_double

get_double : double ($self : self, $name : string)

Set value with a key. the value is converted to double type.

set

set : void ($self : self, $key : string, $val : object)

Set key value pair.

set_byte

set_byte : void ($self : self, $name : string, $value : byte)

Set key and value pair. byte value is converted to SPVM::Byte object.

set_short

set_short : void ($self : self, $name : string, $value : short)

Set key and value pair. short value is converted to SPVM::Short object.

set_int

set_int : void ($self : self, $name : string, $value : int)

Set key and value pair. int value is converted to SPVM::Int object.

set_long

set_long : void ($self : self, $name : string, $value : long)

Set key and value pair. long value is converted to SPVM::Long object.

set_float

set_float : void ($self : self, $name : string, $value : float)

Set key and value pair. float value is converted to SPVM::Float object.

set_double

set_double : void ($self : self, $name : string, $value : double)

Set key and value pair. double value is converted to SPVM::Double object.

set_string

set_string : void ($self : self, $name : string, $value : string)

Set key and value pair with string value..