C<static method new : L<Hash|SPVM::Hash> ($key_values: object[] = undef);>
Creates a new L<Hash|SPVM::Hash> object givenkey-value pairs $key_values.
Examples:
my$book= Hash->new;
my$book= Hash->new({});
my$book= Hash->new({id=> 4, name=> "Perl"});
=head1 Instance Methods
=head2 copy
C<method copy : L<Hash|SPVM::Hash> ();>
Creates a new L<Hash|SPVM::Hash> object, and copies the keysand valuesof the current hash to the new hash, and returns it.
This is not deep copy. The keysare got by L</"keys"> method. The valuesare got by L</"get"> method.
=head2 clone
C<method clone : L<Hash|SPVM::Hash> ();>
The alias forL</"copy"> method.
=head2 delete
C<method delete: object ($key: string);>
Deletes the key and value givenby the key $key.
The deleted value is returned.
Exceptions:
The key $keymust be defined. Otherwise, an exception is thrown.
=head2 exists
C<method exists: int($key: string);>
Checks ifthe value specified by the key $keyexists. If it exists, returns 1. Otherwise returns 0.
=head2 keys
C<method keys: string[] ();>
Gets the keysin the hash. This method does not copy the strings.
=head2 values
C<method values: object[] ();>
Gets all the valuesin the hash.
=head2 get
C<method get : object ($key: string);>
Gets the value specifed by the key $key, and returns it.
If the value does not exist, returns undef.
Exceptions:
The key $keymust be defined. Otherwise, an exception is thrown.
=head2 weaken
C<method weaken : void ($key: string));>
Enables a weaken reference of the field that stores the value specifed by the key $keyifthe value exists.
Exceptions:
The key $keymust be defined. Otherwise, an exception is thrown.
=head2 unweaken
C<method unweaken : void ($key: string);>
Disables a weaken reference of the field that stores the value specifed by the key $keyifthe value exists.
Exceptions:
The key $keymust be defined. Otherwise, an exception is thrown.
=head2 isweak
C<method isweak : int($key: string)>
If the field that stores the value specifed by the key $keyis weakened, returns 1, otherwise returns 0.
Exceptions:
The key $keymust be defined. Otherwise, an exception is thrown.
=head2 get_byte
C<method get_byte : int($key: string);>
Gets the value specifed by the key $keyusing the L<"get"> method, and casts it to byte type, and casts it to inttype, and returns it.
Exceptions:
The type of the value forthe key must be L<Byte|SPVM::Byte>. Otherwise, an exception is thrown.
=head2 get_short
C<method get_short : int($key: string);>
Gets the value specifed by the key $keyusing the L<"get"> method, and casts it to intvalue, and returns it.
Exceptions:
The type of the value forthe key must be L<Short|SPVM::Short> or L<Byte|SPVM::Byte>. Otherwise, an exception is thrown.
=head2 get_int
C<method get_int : int($key: string);>
Gets the value specifed by the key $keyusing the L<"get"> method, and casts it to intvalue, and returns it.
Exceptions:
The type of the value forthe key must be L<Int|SPVM::Int>, L<Short|SPVM::Short>, or L<Byte|SPVM::Byte>. Otherwise, an exception is thrown.
=head2 get_long
C<method get_long : long ($key: string);>
Gets the value specifed by the key $keyusing the L<"get"> method, and casts it to long value, and returns it.
Exceptions:
The type of the value forthe key must be L<Long|SPVM::Long>, L<Int|SPVM::Int>, L<Short|SPVM::Short>, or L<Byte|SPVM::Byte>. Otherwise, an exception is thrown.
=head2 get_float
C<method get_float : float ($key: string);>
Gets the value specifed by the key $keyusing the L<"get"> method, and casts it to float type, and returns it.
Exceptions:
The type of the value forthe key must be L<Float|SPVM::Float>. Otherwise, an exception is thrown.
=head2 get_double
C<method get_double : double ($key: string);>
Gets the value specifed by the key $keyusing the L<"get"> method, and casts it to double type, and returns it.
Exceptions:
The type of the value forthe key must be L<Double|SPVM::Double>. Otherwise, an exception is thrown.
=head2 get_string
C<method get_string : string ($key: string)>
Gets the value specifed by the key $keyusing the L<"get"> method, and casts it to string type, and returns it.
Exceptions:
The type of the value forthe key must be string type. Otherwise, an exception is thrown.
=head2 set
C<method set : void ($key: string, $value: object);>
Sets $valueto the hash by the key $key.
Exceptions:
The key $keymust be defined. Otherwise, an exception is thrown.