From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,deb99d30f6cbcdbe X-Google-Attributes: gid103376,public From: ncohen@watson.ibm.com (Norman H. Cohen) Subject: Re: Hashing Algorithms Date: 1996/03/25 Message-ID: <4j72g2$lbn@watnews1.watson.ibm.com>#1/1 X-Deja-AN: 144202964 distribution: world references: organization: IBM T.J. Watson Research Center reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada Date: 1996-03-25T00:00:00+00:00 List-Id: In article , David Wallace writes: |> Ia working currently with a Design Issue which requiresbthe use of a hashing |> algorithm for a string to an integer. |> |> I have seen a couple of algorithms, however due to their nature would not be |> allowed to incorporate them in to the software. Does "due to their nature" mean "due to the fact that they use unchecked conversion"? |> Could anybody point out the source of some hashing algorithms, which are |> quick and do not use unchecked conversion within them. If not, I will just have |> to reinvent the wheel and write one myself. 1. If your goal is to treat a character as a numeric value, you don't need unchecked conversion. Just use Character'Pos. 2. I think I smell a silly coding rule. While unchecked conversion, should, in general, be used with caution, there are circumstances in which its use is appropriate and perhaps even unavoidable. For example, if you were building a hash table of trees to ensure that there is a unique copy of each subtree ever constructed, it would be appropriate to hash access values pointing to tree nodes by uncheckedly converting them to some integer type. -- Norman H. Cohen ncohen@watson.ibm.com