Ruby: internal/set_table.h Source File

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

set_table.h
1#ifndef INTERNAL_SET_TABLE_H
2#define INTERNAL_SET_TABLE_H
3
4#include "ruby/st.h"
5
6struct set_table_entry;
7
8typedef struct set_table_entry set_table_entry;
9
10 struct set_table {
11 /* Cached features of the table -- see st.c for more details. */
12 unsigned char entry_power, bin_power, size_ind;
13 /* How many times the table was rebuilt. */
14 unsigned int rebuilds_num;
15 const struct st_hash_type *type;
16 /* Number of entries currently in the table. */
17 st_index_t num_entries;
18
19 /* Start and bound index of entries in array entries.
20 entries_starts and entries_bound are in interval
21 [0,allocated_entries]. */
22 st_index_t entries_start, entries_bound;
23
28 set_table_entry *entries;
29};
30
31typedef struct set_table set_table;
32
33typedef int set_foreach_callback_func(st_data_t, st_data_t);
34typedef int set_foreach_check_callback_func(st_data_t, st_data_t, int);
35typedef int set_update_callback_func(st_data_t *key, st_data_t arg, int existing);
36
37#define set_table_size rb_set_table_size
38size_t rb_set_table_size(const struct set_table *tbl);
39#define set_init_table_with_size rb_set_init_table_with_size
40 set_table *rb_set_init_table_with_size(set_table *tab, const struct st_hash_type *, st_index_t);
41#define set_init_numtable rb_set_init_numtable
42 set_table *rb_set_init_numtable(void);
43#define set_init_numtable_with_size rb_set_init_numtable_with_size
44 set_table *rb_set_init_numtable_with_size(st_index_t size);
45#define set_table_delete rb_set_table_delete
46int rb_set_table_delete(set_table *, st_data_t *); /* returns 0:notfound 1:deleted */
47#define set_insert rb_set_insert
48int rb_set_insert(set_table *, st_data_t);
49#define set_table_lookup rb_set_table_lookup
50int rb_set_table_lookup(set_table *, st_data_t);
51#define set_foreach_with_replace rb_set_foreach_with_replace
52int rb_set_foreach_with_replace(set_table *tab, set_foreach_check_callback_func *func, set_update_callback_func *replace, st_data_t arg);
53#define set_table_foreach rb_set_table_foreach
54int rb_set_table_foreach(set_table *, set_foreach_callback_func *, st_data_t);
55#define set_foreach_check rb_set_foreach_check
56int rb_set_foreach_check(set_table *, set_foreach_check_callback_func *, st_data_t, st_data_t);
57#define set_keys rb_set_keys
58st_index_t rb_set_keys(set_table *table, st_data_t *keys, st_index_t size);
59#define set_free_table rb_set_free_table
60void rb_set_free_table(set_table *);
61#define set_table_clear rb_set_table_clear
62void rb_set_table_clear(set_table *);
63#define set_copy rb_set_copy
64 set_table *rb_set_copy(set_table *new_table, set_table *old_table);
65#define set_memsize rb_set_memsize
66PUREFUNC(size_t rb_set_memsize(const set_table *));
67#define set_compact_table rb_set_compact_table
68void set_compact_table(set_table *tab);
69
70#endif
set_table
Definition set_table.h:10
set_table::entries
set_table_entry * entries
Array of size 2^entry_power.
Definition set_table.h:28