Ruby: include/ruby/internal/intern/hash.h Source File

Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)

hash.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_HASH_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_HASH_H
23#include "ruby/internal/attr/nonnull.h"
24#include "ruby/internal/dllexport.h"
25#include "ruby/internal/value.h"
26#include "ruby/st.h"
27
28 RBIMPL_SYMBOL_EXPORT_BEGIN()
29
30/* hash.c */
31
32 RBIMPL_ATTR_NONNULL(())
48 void rb_st_foreach_safe(struct st_table *st, st_foreach_callback_func *func, st_data_t arg);
49
51#define st_foreach_safe rb_st_foreach_safe
52
70 VALUE rb_check_hash_type(VALUE obj);
71
72 RBIMPL_ATTR_NONNULL(())
83void rb_hash_foreach(VALUE hash, int (*func)(VALUE key, VALUE val, VALUE arg), VALUE arg);
84
100 VALUE rb_hash(VALUE obj);
101
107 VALUE rb_hash_new(void);
108
118 VALUE rb_hash_new_capa(long capa);
119
127 VALUE rb_hash_dup(VALUE hash);
128
130 VALUE rb_hash_freeze(VALUE obj);
131
142 VALUE rb_hash_aref(VALUE hash, VALUE key);
143
156 VALUE rb_hash_lookup(VALUE hash, VALUE key);
157
181 VALUE rb_hash_lookup2(VALUE hash, VALUE key, VALUE def);
182
193 VALUE rb_hash_fetch(VALUE hash, VALUE key);
194
208 VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val);
209
218 VALUE rb_hash_clear(VALUE hash);
219
229 VALUE rb_hash_delete_if(VALUE hash);
230
240 VALUE rb_hash_delete(VALUE hash, VALUE key);
241
259void rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash);
260
269typedef VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value);
270
285 VALUE rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func);
286
287/* file.c */
288
297int rb_path_check(const char *path);
298
299/* hash.c */
300
307 VALUE rb_env_clear(void);
308
316 VALUE rb_hash_size(VALUE hash);
317
318 RBIMPL_SYMBOL_EXPORT_END()
319
320#endif /* RBIMPL_INTERN_HASH_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_hash_size
VALUE rb_hash_size(VALUE hash)
Identical to RHASH_SIZE(), except it returns the size in Ruby's integer instead of C's.
Definition hash.c:2968
rb_hash_bulk_insert
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.
Definition hash.c:4736
rb_hash_foreach
void rb_hash_foreach(VALUE hash, int(*func)(VALUE key, VALUE val, VALUE arg), VALUE arg)
Iterates over a hash.
rb_check_hash_type
VALUE rb_check_hash_type(VALUE obj)
Try converting an object to its hash representation using its to_hash method, if any.
Definition hash.c:1878
rb_st_foreach_safe
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 tabl...
rb_hash_lookup2
VALUE rb_hash_lookup2(VALUE hash, VALUE key, VALUE def)
Identical to rb_hash_lookup(), except you can specify what to return on misshits.
Definition hash.c:2100
rb_path_check
int rb_path_check(const char *path)
This function is mysterious.
Definition file.c:6324
rb_hash_freeze
VALUE rb_hash_freeze(VALUE obj)
Just another name of rb_obj_freeze.
Definition hash.c:105
rb_hash_update_func
VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value)
Type of callback functions to pass to rb_hash_update_by().
Definition hash.h:269
rb_hash_delete
VALUE rb_hash_delete(VALUE hash, VALUE key)
Deletes the passed key from the passed hash table, if any.
Definition hash.c:2367
rb_hash_new_capa
VALUE rb_hash_new_capa(long capa)
Identical to rb_hash_new(), except it additionally specifies how many keys it is expected to contain.
Definition hash.c:1490
rb_hash_fetch
VALUE rb_hash_fetch(VALUE hash, VALUE key)
Identical to rb_hash_lookup(), except it yields the (implicitly) passed block instead of returning RU...
Definition hash.c:2178
rb_hash_delete_if
VALUE rb_hash_delete_if(VALUE hash)
Deletes each entry for which the block returns a truthy value.
Definition hash.c:2530
rb_hash_update_by
VALUE rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func)
Destructively merges two hash tables into one.
Definition hash.c:3991
rb_hash_aref
VALUE rb_hash_aref(VALUE hash, VALUE key)
Queries the given key in the given hash table.
Definition hash.c:2087
rb_env_clear
VALUE rb_env_clear(void)
Destructively removes every environment variables of the running process.
Definition hash.c:5847
rb_hash_dup
VALUE rb_hash_dup(VALUE hash)
Duplicates a hash.
Definition hash.c:1550
rb_hash
VALUE rb_hash(VALUE obj)
Calculates a message authentication code of the passed object.
Definition hash.c:247
rb_hash_new
VALUE rb_hash_new(void)
Creates a new, empty hash object.
Definition hash.c:1462
capa
int capa
Designed capacity of the buffer.
Definition io.h:11
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
st_table
Definition st.h:79
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40