Author: Mathieu Pagé
Date: 14:29:28 06/20/04
Go up one level in this thread
Hi Eric,
I don't know anything about fruit, but I think (from experience) that size will
_always_ of the form:
size = 2^X
This allow to have a fast KeyToIndex function that will use a binary operation
and no division. Let's takle your own example, but instead of size = 33 let's
take size = 32 that is 2^6
you have size = 32 (or 100000b)
so your mask is 32 - 1 = 31 (or 11111b)
so when you do:
key & mask
you always get something >= 0 and < 32
So the key is to have a size that is a power of 2.
You could also use any value for the size and take the remainder of the division
as a index, but you will have to problem in this case:
1) for some size you will get a non-uniform distribution of you entries
2) a division is slower than a binary AND (That is in fact a modulo 2)
hope it help.
Mathieu P.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.