ハッシュのデータ構造

id:shckorさんコメント消しちゃってスミマセン!
ハッシュキーは「数値」だ。Perlのソースが手元にあったのでハッシュのデータ構造を見てみたらハッシュキーは32bit unsigned int valueだそうだ。


/* typedefs to eliminate some typing */
typedef struct he HE;
typedef struct hek HEK;

/* entry in hash value chain */
struct he {
HE *hent_next; /* next entry in chain */
HEK *hent_hek; /* hash key */
SV *hent_val; /* scalar value that was hashed */
};

/* hash key -- defined separately for use as shared pointer */
struct hek {
U32 hek_hash; /* hash of key */
I32 hek_len; /* length of hash key */
char hek_key[1]; /* variable-length hash key */
};

/* hash structure: */
/* This structure must match the beginning of struct xpvmg in sv.h. */
struct xpvhv {
char * xhv_array; /* pointer to malloced string */
STRLEN xhv_fill; /* how full xhv_array currently is */
STRLEN xhv_max; /* subscript of last element of xhv_array */
IV xhv_keys; /* how many elements in the array */
NV xnv_nv; /* numeric value, if any */
MAGIC* xmg_magic; /* magic for scalar array */
HV* xmg_stash; /* class package */

I32 xhv_riter; /* current root of iterator */
HE *xhv_eiter; /* current entry of iterator */
PMOP *xhv_pmroot; /* list of pm's for this package */
char *xhv_name; /* name, if a symbol table */
};