Why do you name it "data_key"? Isn't it simply a (structured) 64 bit value, and wouldn't it be better to call it "data" or "value" instead of "data_key"? I'd assume you won't lookup anything in your hash table using that "data_key".Daniel Shawul wrote:Indeed, I don't use such tricks where structs/unions will do. The only place for it in chess engines is for representing a MOVE where bitfields may be slower.Code: Select all
typedef struct tagHASH { HASHKEY hash_key; union { HASHKEY data_key; struct { UBMP32 move; BMP16 score; UBMP8 depth; UBMP8 flags; }; }; }HASH,*PHASH;
In order to access the whole 64 bit structure at once (if you really see the need for it) you might as well omit the union and use a name for the struct, as in:
Code: Select all
typedef struct tagHASH {
HASHKEY hash_key;
struct {
UBMP32 move;
BMP16 score;
UBMP8 depth;
UBMP8 flags;
} data;
}HASH,*PHASH;I think that does basically the same as your solution but with even less "trickery", would you agree?
Sven

