Header: mruby/hash.h
Overview
Hash class
Function Summary collapse
-
mrb_value mrb_hash_new_capa(mrb_state *, mrb_int)
-
mrb_value mrb_ensure_hash_type(mrb_state *, mrb_value)
-
mrb_value mrb_check_hash_type(mrb_state *, mrb_value)
-
mrb_value mrb_hash_new(mrb_state *)
Initializes a new hash.
-
void mrb_hash_set(mrb_state *, mrb_value, mrb_value, mrb_value)
Sets a keys and values to hashes.
-
mrb_value mrb_hash_get(mrb_state *, mrb_value, mrb_value)
Gets a value from a key.
-
mrb_value mrb_hash_fetch(mrb_state *, mrb_value, mrb_value, mrb_value)
Gets a value from a key.
-
mrb_value mrb_hash_delete_key(mrb_state *, mrb_value, mrb_value)
Deletes hash key and value pair.
-
mrb_value mrb_hash_keys(mrb_state *, mrb_value)
Gets an array of keys.
-
mrb_bool mrb_hash_key_p(mrb_state *, mrb_value, mrb_value)
Check if the hash has the key.
-
mrb_bool mrb_hash_empty_p(mrb_state *, mrb_value)
Check if the hash is empty.
-
mrb_value mrb_hash_values(mrb_state *, mrb_value)
Gets an array of values.
-
mrb_value mrb_hash_clear(mrb_state *, mrb_value)
Clears the hash.
-
mrb_int mrb_hash_size(mrb_state *, mrb_value)
Get hash size.
-
mrb_value mrb_hash_dup(mrb_state *, mrb_value)
Copies the hash.
-
void mrb_hash_merge(mrb_state *, mrb_value, mrb_value)
Merges two hashes.
-
void mrb_hash_foreach(mrb_state *, struct RHash *, mrb_hash_foreach_func *, void *)
Define Summary
- #define MRUBY_HASH_H
- #define mrb_hash_ptr
- #define mrb_hash_value
- #define RHASH
RHASH_TBL allocates st_table if not available.
- #define RHASH_TBL
- #define RHASH_IFNONE
- #define RHASH_PROCDEFAULT
- #define MRB_HASH_DEFAULT
- #define MRB_HASH_PROC_DEFAULT
- #define MRB_RHASH_DEFAULT_P
- #define MRB_RHASH_PROCDEFAULT_P
Function Details
mrb_value mrb_hash_new_capa(mrb_state * mrb, mrb_int capa)
mrb_value mrb_ensure_hash_type(mrb_state * mrb, mrb_value hash)
mrb_value mrb_check_hash_type(mrb_state * mrb, mrb_value hash)
mrb_value mrb_hash_new(mrb_state * mrb)
Initializes a new hash.
Equivalent to:
Hash.new
void mrb_hash_set(mrb_state * mrb, mrb_value hash, mrb_value key, mrb_value val)
Sets a keys and values to hashes.
Equivalent to:
hash[key] = val
mrb_value mrb_hash_get(mrb_state * mrb, mrb_value hash, mrb_value key)
Gets a value from a key. If the key is not found, the default of the hash is used.
Equivalent to:
hash[key]
mrb_value mrb_hash_fetch(mrb_state * mrb, mrb_value hash, mrb_value key, mrb_value def)
Gets a value from a key. If the key is not found, the default parameter is used.
Equivalent to:
hash.key?(key) ? hash[key] : def
mrb_value mrb_hash_delete_key(mrb_state * mrb, mrb_value hash, mrb_value key)
Deletes hash key and value pair.
Equivalent to:
hash.delete(key)
mrb_value mrb_hash_keys(mrb_state * mrb, mrb_value hash)
Gets an array of keys.
Equivalent to:
hash.keys
mrb_bool mrb_hash_key_p(mrb_state * mrb, mrb_value hash, mrb_value key)
Check if the hash has the key.
Equivalent to:
hash.key?(key)
mrb_bool mrb_hash_empty_p(mrb_state * mrb, mrb_value self)
Check if the hash is empty
Equivalent to:
hash.empty?
mrb_value mrb_hash_values(mrb_state * mrb, mrb_value hash)
Gets an array of values.
Equivalent to:
hash.values
mrb_value mrb_hash_clear(mrb_state * mrb, mrb_value hash)
Clears the hash.
Equivalent to:
hash.clear
mrb_int mrb_hash_size(mrb_state * mrb, mrb_value hash)
Get hash size.
Equivalent to:
hash.size
mrb_value mrb_hash_dup(mrb_state * mrb, mrb_value hash)
Copies the hash.
void mrb_hash_merge(mrb_state * mrb, mrb_value hash1, mrb_value hash2)
Merges two hashes. The first hash will be modified by the second hash.