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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,16016085da246cdf X-Google-Attributes: gid103376,public From: Stephen & Tammy House Subject: Re: Looking for generic hash function Date: 1996/08/16 Message-ID: <3215244B.4BBF@ro.com>#1/1 X-Deja-AN: 174648449 references: <4v23jd$mg9@News.Dal.Ca> to: Robert Grandy content-type: text/plain; charset=us-ascii organization: RENAISSANCE INTERNET SERVICES mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 3.0b6 (Win95; I) Date: 1996-08-16T00:00:00+00:00 List-Id: Robert Grandy wrote: > > Hello, > > I am looking for a function that will return a random-type integer based > on a generic parameter. What I have in mind is: > > generic > type data_type is private; > function get_data_id return Integer; You could try taking in one step further with: generic type data_type is private; type id is (<>); function data_id (d : data_type) return id; function data_id (d : data_type) return id is type integers is array (integer range <>) of integer; local_d : constant data_type := d; --alias I integer array to same location as local_d, basically begin return --normalize sum of all I into id'range end data_id; I don't remember all the syntax of alises, and I'd have to work out the conversion into the id'range, but this should work for big or small data_type structures. Of course, if data_type'size < integer'size, you'll need to have an alternate plan going. You might make a local integer type based upon min(data_type'size, standard.integer'size) to avoid this problem.