Ruby: id_table.h Source File

Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)

id_table.h
1#ifndef RUBY_ID_TABLE_H
2#define RUBY_ID_TABLE_H 1
3#include "ruby/internal/config.h"
4#include <stddef.h>
5#include "ruby/ruby.h"
6
7struct rb_id_table;
8
9/* compatible with ST_* */
10enum rb_id_table_iterator_result {
11 ID_TABLE_CONTINUE = ST_CONTINUE,
12 ID_TABLE_STOP = ST_STOP,
13 ID_TABLE_DELETE = ST_DELETE,
14 ID_TABLE_REPLACE = ST_REPLACE,
15 ID_TABLE_ITERATOR_RESULT_END
16};
17
18struct rb_id_table *rb_id_table_create(size_t size);
19struct rb_id_table *rb_id_table_init(struct rb_id_table *tbl, size_t capa);
20
21void rb_id_table_free(struct rb_id_table *tbl);
22void rb_id_table_free_items(struct rb_id_table *tbl);
23void rb_id_table_clear(struct rb_id_table *tbl);
24
25size_t rb_id_table_memsize(const struct rb_id_table *tbl);
26
27int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
28int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
29int rb_id_table_delete(struct rb_id_table *tbl, ID id);
30
31typedef enum rb_id_table_iterator_result rb_id_table_update_value_callback_func_t(VALUE *val, void *data, int existing);
32typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
33typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
34void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
35void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
36void rb_id_table_foreach_values_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, rb_id_table_update_value_callback_func_t *replace, void *data);
37
38 VALUE rb_managed_id_table_create(const rb_data_type_t *type, size_t capa);
39 VALUE rb_managed_id_table_new(size_t capa);
40 VALUE rb_managed_id_table_dup(VALUE table);
41int rb_managed_id_table_insert(VALUE table, ID id, VALUE val);
42int rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp);
43size_t rb_managed_id_table_size(VALUE table);
44void rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data);
45void rb_managed_id_table_foreach_values(VALUE table, rb_id_table_foreach_values_func_t *func, void *data);
46int rb_managed_id_table_delete(VALUE table, ID id);
47
48extern const rb_data_type_t rb_managed_id_table_type;
49
50 VALUE rb_marked_id_table_new(size_t capa);
51int rb_marked_id_table_insert(VALUE table, ID id, VALUE val);
52 VALUE rb_marked_id_table_dup(VALUE table);
53
54// alisases
55#define rb_marked_id_table_size rb_managed_id_table_size
56#define rb_marked_id_table_lookup rb_managed_id_table_lookup
57#define rb_marked_id_table_foreach rb_managed_id_table_foreach
58#define rb_marked_id_table_foreach_values rb_managed_id_table_foreach_values
59
60RUBY_SYMBOL_EXPORT_BEGIN
61size_t rb_id_table_size(const struct rb_id_table *tbl);
62RUBY_SYMBOL_EXPORT_END
63
64#endif /* RUBY_ID_TABLE_H */
capa
int capa
Designed capacity of the buffer.
Definition io.h:11
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition cxxanyargs.hpp:56
rb_data_type_t
struct rb_data_type_struct rb_data_type_t
This is the struct that holds necessary info for a struct.
Definition rtypeddata.h:205
ruby.h
rb_id_table
Definition id_table.c:41
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40