cern.colt.map
Class PrimeFinder
- java.lang.Object
-
- cern.colt.map.PrimeFinder
-
public class PrimeFinder extends java.lang.ObjectNot of interest for users; only for implementors of hashtables. Used to keep hash table capacities prime numbers.Choosing prime numbers as hash table capacities is a good idea to keep them working fast, particularly under hash table expansions.
However, JDK 1.2, JGL 3.1 and many other toolkits do nothing to keep capacities prime. This class provides efficient means to choose prime capacities.
Choosing a prime is O(log 300) (binary search in a list of 300 int's). Memory requirements: 1 KB static memory.
-
-
Field Summary
Fields Modifier and Type Field and Description static intlargestPrimeThe largest prime this class can generate; currently equal to Integer.MAX_VALUE.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static intnextPrime(int desiredCapacity)Returns a prime number which is>= desiredCapacityand very close todesiredCapacity(within 11% ifdesiredCapacity >= 1000).
-
-
-
Field Detail
-
largestPrime
public static final int largestPrime
The largest prime this class can generate; currently equal to Integer.MAX_VALUE.- See Also:
- Constant Field Values
-
-
Method Detail
-
nextPrime
public static int nextPrime(int desiredCapacity)
Returns a prime number which is>= desiredCapacityand very close todesiredCapacity(within 11% ifdesiredCapacity >= 1000).- Parameters:
desiredCapacity- the capacity desired by the user.- Returns:
- the capacity which should be used for a hashtable.
-
-
DMelt 3.0 © DataMelt by jWork.ORG