Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.programming,comp.unix.programmer Subject: Re: hash function over IP address Date: Thu, 05 Apr 2012 18:12:16 +0100 Lines: 32 Message-ID: <87sjgi3xxr.fsf@sapphire.mobileactivedefense.com> References: <87hawzyy3z.fsf@blp.benpfaff.org> <87398jw4ep.fsf@sapphire.mobileactivedefense.com> <87d37nyvjw.fsf@blp.benpfaff.org> <87k41uo2ph.fsf@sapphire.mobileactivedefense.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net XmtJvvXPGVxmDKVjstaB+AOvDpV7FK89MEq96+0D3N1d9k/no= Cancel-Lock: sha1:ogh/1Mp5MzjT5+i6WITet4mjnCA= sha1:ZIB8FXf5Z3IvXpvtcaUBEhjsdJ8= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: csiph.com comp.programming:1432 comp.unix.programmer:2373 Daniel Pitts writes: > On 4/5/12 4:08 AM, Rainer Weikusat wrote: >> blp@cs.stanford.edu (Ben Pfaff) writes: >>> Rainer Weikusat writes: >>> >>>> Ben Pfaff writes: >>>>> "Mark" writes: >>>>> >>>>>> I'm trying to find a way create a hash value over multiple IP addresses (I >>>>>> keep a list of IP addresses and its number is variable. The simplest method >>>>>> I've found so far is (obviously not the most effective and collision free): >>>>> >>>>> Why not use one of many available high-quality hash functions? >>>>> Three that come to mind without even going to a search engine: >>>>> Jenkins lookup3, murmurhash, FNV. >>>> >>>> The simple answer is these hash functions are designed to be used for >>>> large, variable length string keys NOT for small, fixed-size >>>> quantities which can be compared with a single machine instruction. >>>> >>>> http://burtleburtle.net/bob/hash/integer.html >>>> http://www.cris.com/~Ttwang/tech/inthash.htm >>> >>> He has a list of multiple IP addresses. A hash function for >>> variable length keys may well be appropriate. >> >> Calculating the hash value must be cheaper than the full comparisons >> which will be needed for a linear search. > Really? How do you hash a string then? Really. If calculating the hash value is more expensive than the comparisons it is supposed to avoid, it obviously buys you nothing.