2015-09-17 11:24:54 +03:00
|
|
|
#ifndef RUBY_ID_TABLE_H
|
|
|
|
#define RUBY_ID_TABLE_H 1
|
2020-05-08 12:31:09 +03:00
|
|
|
#include "ruby/internal/config.h"
|
2019-12-04 11:16:30 +03:00
|
|
|
#include <stddef.h>
|
2015-08-12 11:43:55 +03:00
|
|
|
#include "ruby/ruby.h"
|
|
|
|
|
|
|
|
struct rb_id_table;
|
|
|
|
|
|
|
|
/* compatible with ST_* */
|
|
|
|
enum rb_id_table_iterator_result {
|
|
|
|
ID_TABLE_CONTINUE = ST_CONTINUE,
|
|
|
|
ID_TABLE_STOP = ST_STOP,
|
|
|
|
ID_TABLE_DELETE = ST_DELETE,
|
2019-04-20 04:19:47 +03:00
|
|
|
ID_TABLE_REPLACE = ST_REPLACE,
|
2019-10-03 06:26:41 +03:00
|
|
|
ID_TABLE_ITERATOR_RESULT_END
|
2015-08-12 11:43:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rb_id_table *rb_id_table_create(size_t size);
|
|
|
|
void rb_id_table_free(struct rb_id_table *tbl);
|
|
|
|
void rb_id_table_clear(struct rb_id_table *tbl);
|
|
|
|
|
2015-11-03 01:18:32 +03:00
|
|
|
size_t rb_id_table_size(const struct rb_id_table *tbl);
|
|
|
|
size_t rb_id_table_memsize(const struct rb_id_table *tbl);
|
2015-08-12 11:43:55 +03:00
|
|
|
|
|
|
|
int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
|
|
|
|
int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
|
|
|
|
int rb_id_table_delete(struct rb_id_table *tbl, ID id);
|
2015-08-26 03:47:10 +03:00
|
|
|
|
2022-01-26 00:11:24 +03:00
|
|
|
typedef enum rb_id_table_iterator_result rb_id_table_update_value_callback_func_t(VALUE *val, void *data, int existing);
|
2015-08-26 03:47:10 +03:00
|
|
|
typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
|
|
|
|
typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
|
|
|
|
void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
|
|
|
|
void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
|
2022-01-26 00:11:24 +03:00
|
|
|
void 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);
|
2015-09-17 11:24:54 +03:00
|
|
|
|
|
|
|
#endif /* RUBY_ID_TABLE_H */
|