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 19:34:49 +0100 Lines: 47 Message-ID: <87hawy3u46.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> <87lima3wxi.fsf@sapphire.mobileactivedefense.com> <5flfr.2467$Nk2.1380@newsfe08.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net W40Jl0dHocDmcW5Sid+fhAXwldMYzQO3jLeSjZn6Vhac1dw0o= Cancel-Lock: sha1:WKddSJOI+lP04dj4jK9DErREsUg= sha1:2q+QnR5oAi6o8LzKTGe+70Ql1Rw= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: csiph.com comp.programming:1436 comp.unix.programmer:2377 Daniel Pitts writes: > On 4/5/12 10:34 AM, Rainer Weikusat wrote: >> 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. > Yes, I single hash operation is used so that you can avoid multiple > (meaning plural) comparisons. I said exactly what I meant, and meant > exactly what I said. My point still stands. A hash can be slower than > a comparison, and still save you a significant amount of time. And so did I, superbrain. Please pester someone else in future.