Author: Dann Corbit
Date: 22:54:35 02/18/02
Go up one level in this thread
On February 19, 2002 at 01:48:51, David Rasmussen wrote: > >Eh... How about just using the mod operator, %? > >On February 18, 2002 at 16:41:31, Dann Corbit wrote: > >>On February 18, 2002 at 15:43:09, Alvaro Jose Povoa Cardoso wrote: >> >>>My program uses hash tables witch are a power of two. >>>In order to compute the index to an hash table of this kind I simply do: >>> hashindex=(hashkey & hashsize) >>>in witch hashsize is a mask with for example the first 12 bits set for a size of >>>4096 entries. >>>I would like to know how to compute the index to a hash table that can have >>>sizes like 1MB, 7MB, 45MB, 49MB, 50MB, ..etc >>>Could someone please explain how to do this? >> >>Let's suppose that you want some size of 49MB. Find the smallest prime number >>that is less than or equal to your target size (it's easier than it sounds). >> >>Now, to hash to your table, the lookup is: >>hashindex = hashkey % hashsize; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You mean like this?
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.