PCJ API
Version 1.2

bak.pcj.hash
Class Primes

java.lang.Object
  extended bybak.pcj.hash.Primes

public class Primes
extends Object

This class provides a static table of int sized prime numbers. For small numbers (0-511) it contains all primes. For larger numbers it contains 32 primes each time the number of bits is increased. I.e., there are 32 primes from 512 to 1023, 32 primes from 1024 to 2048, etc., the primes thus becoming less dense with size. Within the interval formed by using one more bit (say, v0 to v1), the 32 primes are formed by searching for the first prime greater than or equal to v0 + n*(v1-v0)/32, n belonging to {0,1,2, ..., 31}. This creates a reasonable distribution.

Since:
1.0

Method Summary
static int nextPrime(int n)
          Returns from a static prime table the least prime that is greater than or equal to a specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

nextPrime

public static int nextPrime(int n)
Returns from a static prime table the least prime that is greater than or equal to a specified value. On average, the returned prime will about 1/64 of 2(r+1) - 2r greater than n, where r is the order of n (the number of bits required for representing it).

Returns:
the least prime in the table that is greater than or equal to the specified value.

PCJ API
Version 1.2

Report a bug or request a feature.
Further information on the development and latest release of PCJ can be found at the project homepage.

Primitive Collections for Java is released under the GNU Lesser General Public License.
Copyright © 2002, 2003 Søren Bak. All Rights Reserved.

Hosted by SourceForge.net
SourceForge.net Logo