Header: mruby/hash.h
Overview
offset of iv must be 3 words
Function Summary collapse
- mrb_value mrb_hash_new_capa(mrb_state *, mrb_int)
-
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
- #define MRB_HASH_IB_BIT_BIT
- #define MRB_HASH_AR_EA_CAPA_BIT
- #define MRB_HASH_IB_BIT_SHIFT
- #define MRB_HASH_AR_EA_CAPA_SHIFT
- #define MRB_HASH_AR_EA_N_USED_SHIFT
- #define MRB_HASH_SIZE_FLAGS_SHIFT
- #define MRB_HASH_IB_BIT_MASK
- #define MRB_HASH_AR_EA_CAPA_MASK
- #define MRB_HASH_AR_EA_N_USED_MASK
- #define MRB_HASH_DEFAULT
- #define MRB_HASH_PROC_DEFAULT
- #define MRB_HASH_HT
- #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_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. This function does NOT copy the instance variables (except for the default value). Use mrb_obj_dup() to copy the instance variables as well.
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.