Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FiveWin 1.9.2 - January 97 - nstrhash() returns a unique hash value for a string http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 nStrHash()             Returns a unique hash value for a string
--------------------------------------------------------------------------------

   Syntax:              nStrHash( <cString>, <nHashRange> )
                                    --> <nHashValue>

   Parameters:

   <cString>            Is the string to calculate a numeric hash value.

   <nHashRange>         Is the numeric range for the hash value.

   Returns:

   <nHashValue>         A numeric value corresponding to a unique hash
                        value for that specific string.

   Observations:        Hash techniques is a powerfull way to increase
                        speed doing a search. Given a string we calculate
                        its hash value, and using that hashvalue we know
                        exactly where a certain string will be located in
                        a given array.

   Sample:

                        local aStrings := Array( 50 )

                        aStrings[ nStrHash( "Test", 50 ) ] = { "Test",;
                                                               "related value" }
                        ...

                        MsgInfo( aStrings[ nStrHash( "Test", 50 ) ][ 2 ] )
                        // we don't need to search "Test", we simply
                        // locate it based on its hash value!
                        // We can do the same with other strings values

   Source code:         SOURCE\\FUNCTION\\Hash.c


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson