Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created June 15, 2009 23:04
Show Gist options
  • Select an option

  • Save methodmissing/130413 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/130413 to your computer and use it in GitHub Desktop.
typedef unsigned long rb_value_t;
typedef unsigned long rb_id_t;
typedef unsigned long st_data_t;
struct st_table_entry {
unsigned int hash;
st_data_t key;
st_data_t record;
caddr_t next;
};
translator struct st_table_entry < struct st_table_entry *STE > {
hash = STE->hash;
key = STE->key;
record = STE->record;
next = (caddr_t)STE->next;
};
struct st_hash_type {
int (*compare)();
int (*hash)();
};
translator struct st_hash_type < struct st_hash_type *HT > {
compare = HT->compare;
hash = HT->hash;
};
struct st_table {
struct st_hash_type *type;
int num_bins;
int num_entries;
struct st_table_entry **bins;
};
translator struct st_table < struct st_table *ST > {
type = (struct st_hash_type *)ST->type;
num_bins = ST->num_bins;
num_entries = ST->num_entries;
bins = (struct st_table_entry **)ST->bins;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment