SPVM::Hash - Hash Data Structure
use SPVM::Hash; # Create hash my $book = SPVM::Hash->new({}); $book->set_int(id => 4); $book->set_string(name => "Perl"); $book->set_double(price => 3000.0); my $id = (int)$book->get_int("id"); my $name = (string)$book->get_string("name"); my $price = (double)$book->get_double("price"); # Create hash with key value pairs my $book = SPVM::Hash->new({id => 4, name => "Perl", price => 3000.0});
SPVM::Hash is Hash Data Structure. This is generally called associative array.
sub new : SPVM::Hash ($key_values : oarray)
Create a new SPVM::Hash object with key value pairs.
# Create hash my $book = SPVM::Hash->new({}); # Create hash with key value pairs my $book = SPVM::Hash->new({id => 4, name => "Perl"});
count : int ($self : self)
Count keys.
copy : SPVM::Hash ($self : self)
Copy hash.
This is not deep copy. Address of keys and values is copied into new hash.
delete : object ($self : self, $key : string)
Delete a key value pair. Deleted value is returned.
exists : int ($self : self, $key : string)
Specify the key and check if the value exists. If exists, return 1, otherwise 0.
keys : string[] ($self : self)
Get keys. This method do not copy the strings.
values : object[] ($self : self)
Get values.
get : object ($self : self, $key : string)
Get a value.
get_byte : byte ($self : self, $name : string)
Get value with a key. the value is converted to byte type.
get_short : short ($self : self, $name : string)
Get value with a key. the value is converted to short type.
get_int : int ($self : self, $name : string)
Get value with a key. the value is converted to int type.
get_long : long ($self : self, $name : string)
Get value with a key. the value is converted to long type.
get_float : float ($self : self, $name : string)
Get value with a key. the value is converted to float type.
get_double : double ($self : self, $name : string)
Get value with a key. the value is converted to double type.
set : void ($self : self, $key : string, $val : object)
Set key value pair.
set_byte : void ($self : self, $name : string, $value : byte)
Set key and value pair. byte value is converted to SPVM::Byte object.
set_short : void ($self : self, $name : string, $value : short)
Set key and value pair. short value is converted to SPVM::Short object.
set_int : void ($self : self, $name : string, $value : int)
Set key and value pair. int value is converted to SPVM::Int object.
set_long : void ($self : self, $name : string, $value : long)
Set key and value pair. long value is converted to SPVM::Long object.
set_float : void ($self : self, $name : string, $value : float)
Set key and value pair. float value is converted to SPVM::Float object.
set_double : void ($self : self, $name : string, $value : double)
Set key and value pair. double value is converted to SPVM::Double object.
set_string : void ($self : self, $name : string, $value : string)
Set key and value pair with string value.
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.