home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!cs.utexas.edu!torn!watserv1!watmath!undergrad.math.waterloo.edu!cayley.waterloo.edu!amichail
- From: amichail@cayley.waterloo.edu (Amir Michail)
- Subject: Re: finding 1st one in integer
- Message-ID: <BrsMBE.98t@undergrad.math.waterloo.edu>
- Sender: news@undergrad.math.waterloo.edu
- Organization: University of Waterloo
- References: <Brqu3F.1J4@undergrad.math.waterloo.edu> <LOWRY.92Jul21165844@rotor.watson.ibm.com>
- Date: Wed, 22 Jul 1992 13:47:38 GMT
- Lines: 23
-
- In article <LOWRY.92Jul21165844@rotor.watson.ibm.com>, lowry@watson.ibm.com (Andy Lowry) writes:
- > This seems to work nicely:
- >
- > int firstone(x)
- > unsigned int x;
- > {
- > static int keys[] = {
- > -1, 0, 1, 26, 2, 23, 27, -1, 3, 16,
- > 24, 30, 28, 11, -1, 13, 4, 7, 17, -1,
- > 25, 22, 31, 15, 29, 10, 12, 6, -1, 21,
- > 14, 9, 5, 20, 8, 19, 18 };
- >
- > return keys[x % 37];
- > }
- >
-
- Yes, I thought of this method initially. The only problem is that the
- modulus operation is *VERY* slow on some architectures such as the sparc.
- Perhaps there is a simpler hashing function? I have not been successful
- in finding one.
-
- Amir
-
-