Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!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:34:01 +0100 Lines: 40 Message-ID: <87lima3wxi.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> <87sjgi3xxr.fsf@sapphire.mobileactivedefense.com> <_xkfr.45660$QC3.18854@newsfe16.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net agIxArTuR8nDVyRbogSEOgVOYTfXPy9XSCyifvY8EWYnN3TsU= Cancel-Lock: sha1:XXqczwJLiHJ+x2IPCPLrtzyGK6M= sha1:BgSwr4W503emXpJgoIgqPCq4/wQ= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: csiph.com comp.programming:1434 comp.unix.programmer:2375 Daniel Pitts writes: > On 4/5/12 10:12 AM, Rainer Weikusat wrote: >> 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. > A single hash is supposed to save you multiple comparisons, not a > single comparison, An the letter 's' following a word, as in comparisonS, is supposed to indicate a plural.