home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / programm / 2054 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.1 KB  |  35 lines

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