* 2022-01-18 [ci skip]
[ruby-80x24.org.git] / id_table.h
blobf3dc681d1760d90001c88e117c719e3c121882b8
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"
7 struct rb_id_table;
9 /* compatible with ST_* */
10 enum 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
18 struct rb_id_table *rb_id_table_create(size_t size);
19 void rb_id_table_free(struct rb_id_table *tbl);
20 void rb_id_table_clear(struct rb_id_table *tbl);
22 size_t rb_id_table_size(const struct rb_id_table *tbl);
23 size_t rb_id_table_memsize(const struct rb_id_table *tbl);
25 int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
26 int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
27 int rb_id_table_delete(struct rb_id_table *tbl, ID id);
29 typedef enum rb_id_table_iterator_result rb_id_table_update_callback_func_t(ID *id, VALUE *val, void *data, int existing);
30 typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
31 typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
32 void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
33 void rb_id_table_foreach_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data);
34 void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
36 #endif /* RUBY_ID_TABLE_H */