2000-01-04 23:41:21 -05:00
|
|
|
/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
/* @(#) st.h 5.1 89/12/14 */
|
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#ifndef RUBY_ST_H
|
|
|
|
#define RUBY_ST_H 1
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#if 0
|
|
|
|
} /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
#endif
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-07-09 21:08:15 -04:00
|
|
|
#if SIZEOF_LONG == SIZEOF_VOIDP
|
2003-07-27 13:20:29 -04:00
|
|
|
typedef unsigned long st_data_t;
|
2006-07-09 21:08:15 -04:00
|
|
|
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
|
|
|
typedef unsigned LONG_LONG st_data_t;
|
|
|
|
#else
|
2007-08-31 22:14:40 -04:00
|
|
|
# error ---->> st.c requires sizeof(void*) == sizeof(long) to be compiled. <<----
|
2006-07-09 21:08:15 -04:00
|
|
|
#endif
|
2003-05-20 02:48:04 -04:00
|
|
|
#define ST_DATA_T_DEFINED
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 10:55:43 -05:00
|
|
|
|
2007-08-31 22:14:40 -04:00
|
|
|
#ifndef CHAR_BIT
|
|
|
|
# ifdef HAVE_LIMITS_H
|
|
|
|
# include <limits.h>
|
|
|
|
# else
|
|
|
|
# define CHAR_BIT 8
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#ifndef _
|
|
|
|
# define _(args) args
|
|
|
|
#endif
|
|
|
|
#ifndef ANYARGS
|
|
|
|
# ifdef __cplusplus
|
|
|
|
# define ANYARGS ...
|
|
|
|
# else
|
|
|
|
# define ANYARGS
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
typedef struct st_table st_table;
|
|
|
|
|
2007-08-31 22:14:40 -04:00
|
|
|
typedef int st_compare_func(st_data_t, st_data_t);
|
|
|
|
typedef int st_hash_func(st_data_t);
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
struct st_hash_type {
|
2007-08-31 22:14:40 -04:00
|
|
|
int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
|
|
|
|
int (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
|
1998-01-16 07:13:05 -05:00
|
|
|
};
|
|
|
|
|
2007-09-01 01:24:25 -04:00
|
|
|
typedef st_data_t st_index_t;
|
|
|
|
#define ST_INDEX_BITS (sizeof(st_index_t) * CHAR_BIT)
|
2007-08-31 22:14:40 -04:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
struct st_table {
|
2007-07-04 21:06:49 -04:00
|
|
|
const struct st_hash_type *type;
|
2007-09-02 10:40:47 -04:00
|
|
|
st_index_t num_bins;
|
2007-08-28 22:36:54 -04:00
|
|
|
unsigned int entries_packed : 1;
|
2007-09-02 10:40:47 -04:00
|
|
|
st_index_t num_entries : ST_INDEX_BITS - 1;
|
1999-01-19 23:59:39 -05:00
|
|
|
struct st_table_entry **bins;
|
2007-08-21 00:43:51 -04:00
|
|
|
struct st_table_entry *head;
|
1998-01-16 07:13:05 -05:00
|
|
|
};
|
|
|
|
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 10:55:43 -05:00
|
|
|
#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2004-09-22 00:48:52 -04:00
|
|
|
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
|
|
|
|
2007-07-04 21:06:49 -04:00
|
|
|
st_table *st_init_table(const struct st_hash_type *);
|
|
|
|
st_table *st_init_table_with_size(const struct st_hash_type *, int);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
st_table *st_init_numtable(void);
|
|
|
|
st_table *st_init_numtable_with_size(int);
|
|
|
|
st_table *st_init_strtable(void);
|
|
|
|
st_table *st_init_strtable_with_size(int);
|
|
|
|
int st_delete(st_table *, st_data_t *, st_data_t *);
|
|
|
|
int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
|
|
|
|
int st_insert(st_table *, st_data_t, st_data_t);
|
|
|
|
int st_lookup(st_table *, st_data_t, st_data_t *);
|
|
|
|
int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
|
2007-08-21 00:43:51 -04:00
|
|
|
int st_reverse_foreach(st_table *, int (*)(ANYARGS), st_data_t);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
void st_add_direct(st_table *, st_data_t, st_data_t);
|
|
|
|
void st_free_table(st_table *);
|
|
|
|
void st_cleanup_safe(st_table *, st_data_t);
|
2007-08-21 00:43:51 -04:00
|
|
|
void st_clear(st_table *);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
st_table *st_copy(st_table *);
|
2007-08-31 22:14:40 -04:00
|
|
|
int st_numcmp(st_data_t, st_data_t);
|
|
|
|
int st_numhash(st_data_t);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
#if 0
|
|
|
|
{ /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
} /* extern "C" { */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* RUBY_ST_H */
|