++ed by:
BRDUCH XYF AZJADFTRE POTATOGIM MHOWARD
7 non-PAUSE users
Author image Yuki Kimoto

NAME

SPVM::Hash - Hash Data Structure

SYNOPSYS

  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});

DESCRIPTION

SPVM::Hash is Hash Data Structure. This is generally called associative array.

STATIC METHODS

new

    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"});

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)

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

get_short

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

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

get_int

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

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

get_long

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

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

get_float

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

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

get_double

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

Get 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.