|
| void | rb_st_foreach_safe (struct st_table *st, st_foreach_callback_func *func, st_data_t arg) |
| | Identical to rb_st_foreach(), except it raises exceptions when the callback function tampers the table during iterating over it.
|
| VALUE | rb_check_hash_type (VALUE obj) |
| | Try converting an object to its hash representation using its to_hash method, if any.
|
| void | rb_hash_foreach (VALUE hash, int(*func)(VALUE key, VALUE val, VALUE arg), VALUE arg) |
| | Iterates over a hash.
|
| VALUE | rb_hash (VALUE obj) |
| | Calculates a message authentication code of the passed object.
|
| VALUE | rb_hash_new (void) |
| | Creates a new, empty hash object.
|
| VALUE | rb_hash_new_capa (long capa) |
| | Identical to rb_hash_new(), except it additionally specifies how many keys it is expected to contain.
|
| VALUE | rb_hash_dup (VALUE hash) |
| | Duplicates a hash.
|
| VALUE | rb_hash_freeze (VALUE obj) |
| | Just another name of rb_obj_freeze.
|
| VALUE | rb_hash_aref (VALUE hash, VALUE key) |
| | Queries the given key in the given hash table.
|
| VALUE | rb_hash_lookup (VALUE hash, VALUE key) |
| | Identical to rb_hash_aref(), except it always returns RUBY_Qnil for misshits.
|
| VALUE | rb_hash_lookup2 (VALUE hash, VALUE key, VALUE def) |
| | Identical to rb_hash_lookup(), except you can specify what to return on misshits.
|
| VALUE | rb_hash_fetch (VALUE hash, VALUE key) |
| | Identical to rb_hash_lookup(), except it yields the (implicitly) passed block instead of returning RUBY_Qnil.
|
| VALUE | rb_hash_aset (VALUE hash, VALUE key, VALUE val) |
| | Inserts or replaces ("upsert"s) the objects into the given hash table.
|
| VALUE | rb_hash_clear (VALUE hash) |
| | Swipes everything out of the passed hash table.
|
| VALUE | rb_hash_delete_if (VALUE hash) |
| | Deletes each entry for which the block returns a truthy value.
|
| VALUE | rb_hash_delete (VALUE hash, VALUE key) |
| | Deletes the passed key from the passed hash table, if any.
|
| void | rb_hash_bulk_insert (long argc, const VALUE *argv, VALUE hash) |
| | Inserts a list of key-value pairs into a hash table at once.
|
| VALUE | rb_hash_update_by (VALUE hash1, VALUE hash2, rb_hash_update_func *func) |
| | Destructively merges two hash tables into one.
|
| VALUE | rb_env_clear (void) |
| | Destructively removes every environment variables of the running process.
|
| VALUE | rb_hash_size (VALUE hash) |
| | Identical to RHASH_SIZE(), except it returns the size in Ruby's integer instead of C's.
|
Public APIs related to rb_cHash.
- Author
- Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
- Copyright
- This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.
- Warning
- Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
- Note
- To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.
Definition in file hash.h.
Calculates a message authentication code of the passed object.
The return value is a very small integer used as an index of a key of a table. In order to calculate the value this function calls #hash method of the passed object. Ruby provides you a default implementation. But if you implement your class in C, that default implementation cannot know the underlying data structure. You must implement your own #hash method then, which must return an integer of uniform distribution in a sufficiently instant manner.
- Parameters
-
| [in] | obj | Arbitrary Ruby object. |
- Exceptions
-
| rb_eTypeError | obj.hash returned something non-Integer. |
- Returns
- A small integer.
- Note
- #hash can return very big integers, but they get truncated.
Definition at line 263 of file hash.c.