realbasic-nug
[Top] [All Lists]

Re: Doh! Variant.Hash is case insenstive Re: Variant.Hash for object

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Doh! Variant.Hash is case insenstive Re: Variant.Hash for objects is not unique in RB 2005 v4
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Wed, 30 Nov 2005 08:16:08 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <BFB249F0 dot 5B3D%Roph at kc dot rr dot com>
At 6:09 PM -0600 11/29/05, Roph wrote:

I just discovered that the Variant.Hash method is case-insenstive for
strings.

That's true (and intentional).

1) Fix this by making the hash function case sensitive for strings so it is
usable in case-sensitive algorithms.

They already are. String hashes are necessarily non-unique, so you'll always have to check for collisions anyway. However, the standard behavior for a hash function is that if x = y, then Hash(x) = Hash(y). Since '=' for strings is case insensitive, then it's correct (and important) that Hash for strings be the same. If you want to handle collisions by using StrComp instead of '=', you can still do that.

Best,
- Joe

--
Joe Strout                          REAL Software, Inc.

Vote for REALbasic (twice!) in the LinuxWorld Reader's Choice Awards:
http://linux.sys-con.com/general/readerschoice.htm
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>