1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/id_table.h
normal b147b5a3b8 id_table: const correctness for _size and _memsize
This allows us to swap in rb_id_table_memsize for st_memsize
(which takes a "const st_table *") more easily.

It also makes sense to do the same for rb_id_table_size,
too; as the table cannot be altered when accessing size.

* id_table.h (rb_id_table_size): const arg
  (rb_id_table_memsize): ditto
* id_table.c (st_id_table_size): ditto
  (st_id_table_memsize): ditto
  (list_id_table_size): ditto
  (list_id_table_memsize): ditto
  (hash_id_table_size): ditto
  (hash_id_table_memsize): ditto
  (mix_id_table_size): ditto
  (mix_id_table_memsize): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-02 22:18:32 +00:00

30 lines
1.1 KiB
C

#ifndef RUBY_ID_TABLE_H
#define RUBY_ID_TABLE_H 1
#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,
};
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);
size_t rb_id_table_size(const struct rb_id_table *tbl);
size_t rb_id_table_memsize(const struct rb_id_table *tbl);
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);
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);
#endif /* RUBY_ID_TABLE_H */