#include "config.h"
#include "defines.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "st.h"
Go to the source code of this file.
Data Structures | |
| struct | st_table_entry |
Defines | |
| #define | ST_DEFAULT_MAX_DENSITY 5 |
| #define | ST_DEFAULT_INIT_TABLE_SIZE 11 |
| #define | alloc(type) (type*)malloc((unsigned)sizeof(type)) |
| #define | Calloc(n, s) (char*)calloc((n),(s)) |
| #define | EQUAL(table, x, y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0) |
| #define | do_hash(key, table) (unsigned int)(*(table)->type->hash)((key)) |
| #define | do_hash_bin(key, table) (do_hash(key, table)%(table)->num_bins) |
| #define | MINSIZE 8 |
| #define | PTR_NOT_EQUAL(table, ptr, hash_val, key) ((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key))) |
| #define | COLLISION |
| #define | FIND_ENTRY(table, ptr, hash_val, bin_pos) |
| #define | ADD_DIRECT(table, key, value, hash_val, bin_pos) |
Typedefs | |
| typedef st_table_entry | st_table_entry |
Functions | |
| int | numcmp (long, long) |
| int | numhash (long) |
| int | strhash (const char *) |
| void | rehash (st_table *) |
| int | new_size (int size) |
| st_table * | st_init_table_with_size (struct st_hash_type *type, int size) |
| st_table * | st_init_table (struct st_hash_type *type) |
| st_table * | st_init_numtable (void) |
| st_table * | st_init_numtable_with_size (int size) |
| st_table * | st_init_strtable (void) |
| st_table * | st_init_strtable_with_size (int size) |
| void | st_free_table (st_table *table) |
| int | st_lookup (st_table *table, st_data_t key, st_data_t *value) |
| int | st_insert (st_table *table, st_data_t key, st_data_t value) |
| void | st_add_direct (st_table *table, st_data_t key, st_data_t value) |
| st_table * | st_copy (st_table *old_table) |
| int | st_delete (st_table *table, st_data_t *key, st_data_t *value) |
| int | st_delete_safe (st_table *table, st_data_t *key, st_data_t *value, st_data_t never) |
| int | delete_never (st_data_t key, st_data_t value, st_data_t never) |
| void | st_cleanup_safe (st_table *table, st_data_t never) |
| int | st_foreach (st_table *table, func, st_data_t arg) |
Variables | |
| st_hash_type | type_numhash |
| st_hash_type | type_strhash |
| long | primes [] |
|
|
Value: do {\ st_table_entry *entry;\ if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\ rehash(table);\ bin_pos = hash_val % table->num_bins;\ }\ \ entry = alloc(st_table_entry);\ \ entry->hash = hash_val;\ entry->key = key;\ entry->record = value;\ entry->next = table->bins[bin_pos];\ table->bins[bin_pos] = entry;\ table->num_entries++;\ } while (0) Definition at line 257 of file st.c. Referenced by st_add_direct(), and st_insert(). |
|
|
Definition at line 51 of file st.c. Referenced by extract_path(), st_copy(), and st_init_table_with_size(). |
|
|
Definition at line 52 of file st.c. Referenced by rehash(), st_copy(), and st_init_table_with_size(). |
|
|
|
|
|
Definition at line 56 of file st.c. Referenced by st_add_direct(), st_insert(), and st_lookup(). |
|
|
Definition at line 57 of file st.c. Referenced by st_delete(), and st_delete_safe(). |
|
|
Definition at line 54 of file st.c. Referenced by st_delete(), and st_delete_safe(). |
|
|
Value: do {\ bin_pos = hash_val%(table)->num_bins;\ ptr = (table)->bins[bin_pos];\ if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\ COLLISION;\ while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\ ptr = ptr->next;\ }\ ptr = ptr->next;\ }\ } while (0) Definition at line 224 of file st.c. Referenced by st_insert(), and st_lookup(). |
|
|
Definition at line 63 of file st.c. Referenced by new_size(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 14 of file st.c. Referenced by rehash(), st_copy(), st_delete(), st_delete_safe(), st_foreach(), st_free_table(), st_init_table_with_size(), st_insert(), and st_lookup(). |
|
||||||||||||||||
|
Definition at line 451 of file st.c. References ST_CONTINUE, st_data_t, and ST_DELETE. Referenced by st_cleanup_safe(). |
|
|
Definition at line 101 of file st.c. References MINSIZE, and primes. Referenced by rehash(), and st_init_table_with_size(). |
|
||||||||||||
|
|
|
|
|
|
|
Definition at line 311 of file st.c. References Calloc, free, st_table_entry::hash, new_size(), st_table_entry::next, and st_table_entry. |
|
||||||||||||||||
|
Definition at line 298 of file st.c. References ADD_DIRECT, do_hash, and st_data_t. Referenced by boot_defclass(), define_final(), generic_ivar_set(), method_entry(), rb_alias_variable(), rb_autoload(), rb_copy_generic_ivar(), rb_define_class(), rb_define_module(), rb_global_entry(), rb_hash_aset(), rb_intern(), rb_source_filename(), set_syserr(), w_object(), and w_symbol(). |
|
||||||||||||
|
Definition at line 459 of file st.c. References delete_never(), st_data_t, and st_foreach(). Referenced by hash_foreach_ensure(). |
|
|
Definition at line 337 of file st.c. References alloc, st_table::bins, Calloc, free, st_table_entry::next, and st_table_entry. Referenced by init_copy(), rb_copy_generic_ivar(), rb_hash_s_create(), rb_mod_init_copy(), and rb_singleton_class_clone(). |
|
||||||||||||||||
|
Definition at line 378 of file st.c. References do_hash_bin, EQUAL, free, st_table_entry::key, st_table_entry::next, st_table_entry::record, st_data_t, and st_table_entry. Referenced by autoload_delete(), autoload_file(), classname(), find_class_path(), generic_ivar_remove(), rb_ary_and(), rb_ary_or(), rb_ary_uniq_bang(), rb_free_generic_ivar(), rb_hash_delete(), rb_mod_init_copy(), rb_mod_remove_const(), rb_mod_remove_cvar(), rb_obj_remove_instance_variable(), rb_require_safe(), rb_thread_local_aset(), rb_waitpid(), remove_method(), run_final(), and undefine_final(). |
|
||||||||||||||||||||
|
Definition at line 420 of file st.c. References do_hash_bin, EQUAL, st_table_entry::key, st_table_entry::next, st_table_entry::record, st_data_t, and st_table_entry. Referenced by hash_foreach_iter(), and rb_hash_delete(). |
|
||||||||||||||||
|
Definition at line 470 of file st.c. References free, st_table_entry::key, st_table_entry::next, st_table_entry::record, ST_CHECK, ST_CONTINUE, st_data_t, ST_DELETE, st_retval, ST_STOP, and st_table_entry. |
|
|
Definition at line 197 of file st.c. References free, st_table_entry::next, and st_table_entry. Referenced by autoload_delete(), autoload_file(), check_autoload_table(), class_instance_method_list(), dump_ensure(), generic_ivar_remove(), init_copy(), load_ensure(), obj_free(), rb_autoload(), rb_const_list(), rb_copy_generic_ivar(), rb_free_generic_ivar(), rb_hash_rehash(), rb_obj_singleton_methods(), and thread_free(). |
|
|
Definition at line 171 of file st.c. References st_init_table(), and type_numhash. Referenced by class_instance_method_list(), define_final(), find_class_path(), generic_ivar_set(), include_class_new(), Init_Exception(), Init_var_tables(), marshal_dump(), marshal_load(), mod_av_set(), rb_autoload(), rb_class_boot(), rb_ivar_set(), rb_mod_const_at(), rb_mod_init_copy(), rb_module_new(), rb_obj_singleton_methods(), rb_singleton_class_attached(), rb_singleton_class_clone(), rb_thread_local_aset(), and rb_waitpid(). |
|
|
Definition at line 177 of file st.c. References st_init_table_with_size(), and type_numhash. Referenced by Init_sym(). |
|
|
Definition at line 184 of file st.c. References st_init_table(), and type_strhash. Referenced by Init_GC(), and rb_require_safe(). |
|
|
Definition at line 190 of file st.c. References st_init_table_with_size(), and type_strhash. Referenced by Init_sym(). |
|
|
Definition at line 164 of file st.c. References st_init_table_with_size(). Referenced by hash_alloc(), st_init_numtable(), and st_init_strtable(). |
|
||||||||||||
|
Definition at line 139 of file st.c. References alloc, st_table::bins, Calloc, new_size(), st_table::num_bins, st_table::num_entries, st_table_entry, and st_table::type. Referenced by rb_hash_rehash(), st_init_numtable_with_size(), st_init_strtable_with_size(), and st_init_table(). |
|
||||||||||||||||
|
Definition at line 276 of file st.c. References ADD_DIRECT, do_hash, FIND_ENTRY, st_table_entry::record, st_data_t, and st_table_entry. Referenced by classname(), clone_method(), find_class_path(), generic_ivar_set(), mod_av_set(), r_symreal(), rb_add_method(), rb_alias(), rb_autoload(), rb_copy_generic_ivar(), rb_cvar_set(), rb_gc_copy_finalizer(), rb_hash_aset(), rb_hash_rehash_i(), rb_ivar_set(), rb_require_safe(), rb_singleton_class_attached(), rb_thread_local_aset(), rb_waitpid(), and sv_i(). |
|
||||||||||||||||
|
|
|
|
|
Definition at line 68 of file st.c. Referenced by new_size(). |
|
|
Initial value: {
numcmp,
numhash,
}
Definition at line 37 of file st.c. Referenced by st_init_numtable(), and st_init_numtable_with_size(). |
|
|
Initial value: {
strcmp,
strhash,
}
Definition at line 44 of file st.c. Referenced by st_init_strtable(), and st_init_strtable_with_size(). |
1.3.5