Re: Hashtable efficiency
From: Michael Borgwardt (brazil_at_brazils-animeland.de)
Date: 08/21/04
- Next message: Michael Borgwardt: "Re: encoding troubles"
- Previous message: lucy: "how to set focus to an AWT edit field?"
- In reply to: Mike Schilling: "Re: Hashtable efficiency"
- Next in thread: Mike Schilling: "Re: Hashtable efficiency"
- Reply: Mike Schilling: "Re: Hashtable efficiency"
- Reply: Mark Thornton: "Re: Hashtable efficiency"
- Reply: Chris Uppal: "Re: Hashtable efficiency"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 21 Aug 2004 00:46:20 +0200
Mike Schilling wrote:
> Speaking of which, why does HashMap use powers of 2, when we all learned in
> our first data structures class to use odd primes?
Probably because finding primes is a lot more difficult that finding
powers of 2.
The *reason* why you use prime hash table sizes is that it's the simplest
way to defend against non-obviously bad hash functions. Sun's
implementation achieves the same goal with the scrambling method I quoted.
BTW, the only even prime is 2, and nobody's gonna use that as a hash
table size...
- Next message: Michael Borgwardt: "Re: encoding troubles"
- Previous message: lucy: "how to set focus to an AWT edit field?"
- In reply to: Mike Schilling: "Re: Hashtable efficiency"
- Next in thread: Mike Schilling: "Re: Hashtable efficiency"
- Reply: Mike Schilling: "Re: Hashtable efficiency"
- Reply: Mark Thornton: "Re: Hashtable efficiency"
- Reply: Chris Uppal: "Re: Hashtable efficiency"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|