Class PrimesCache
Buy me a cup of coffee via donation
or support me purchasing the license via ORDER Page , or INFIMA online store
java.lang.Object
org.mariuszgromada.math.mxparser.mathcollection.PrimesCache
Class for generating prime numbers cache using
Eratosthenes Sieve.
- Version:
- 5.2.0
- Author:
- Mariusz Gromada
MathParser.org - mXparser project page
mXparser on GitHub
INFIMA place to purchase a commercial MathParser.org-mXparser software license
info@mathparser.org
ScalarMath.org - a powerful math engine and math scripting language
Scalar Lite
Scalar Pro
MathSpace.pl
Buy me a cup of coffee via donation
or support me purchasing the license via ORDER Page , or INFIMA online store
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Empty cache statusstatic final boolean
Cache ready to usestatic final int
Default range of integer to store in cachestatic final int
Indicator if given number is not a primestatic final int
Indicator if given number is a primestatic final int
Indicator that the value is not stored in cache -
Constructor Summary
ConstructorDescriptionDefault constructor - setting prime cache for a default range if integersPrimesCache
(int maxNumInCache) Constructor - setting prime cache for a given range if integers -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns cache statusdouble
Returns computing time of Eratosthenes Sieveint
Returns cache range.int
Returns number of found primes.boolean
Returns true in case when primes cache initialization was successful, otherwise returns false.int
primeTest
(int n) Check whether given number is prime
-
Field Details
-
DEFAULT_MAX_NUM_IN_CACHE
public static final int DEFAULT_MAX_NUM_IN_CACHEDefault range of integer to store in cache- See Also:
-
CACHE_EMPTY
public static final boolean CACHE_EMPTYEmpty cache status- See Also:
-
CACHING_FINISHED
public static final boolean CACHING_FINISHEDCache ready to use- See Also:
-
IS_PRIME
public static final int IS_PRIMEIndicator if given number is a prime- See Also:
-
IS_NOT_PRIME
public static final int IS_NOT_PRIMEIndicator if given number is not a prime- See Also:
-
NOT_IN_CACHE
public static final int NOT_IN_CACHEIndicator that the value is not stored in cache- See Also:
-
-
Constructor Details
-
PrimesCache
public PrimesCache()Default constructor - setting prime cache for a default range if integers -
PrimesCache
public PrimesCache(int maxNumInCache) Constructor - setting prime cache for a given range if integers- Parameters:
maxNumInCache
- Range of integers to be stored in prime cache
-
-
Method Details
-
getComputingTime
public double getComputingTime()Returns computing time of Eratosthenes Sieve- Returns:
- Computing time in seconds
-
getCacheStatus
public boolean getCacheStatus()Returns cache status- Returns:
- PrimesCache.CACHE_EMPTY or PrimesCache.CACHING_FINISHED;
-
getNumberOfPrimes
public int getNumberOfPrimes()Returns number of found primes.- Returns:
- Number of found primes.
-
getMaxNumInCache
public int getMaxNumInCache()Returns cache range.- Returns:
- Maximum integera number in cache/
-
primeTest
public int primeTest(int n) Check whether given number is prime- Parameters:
n
- Given integer number.- Returns:
- PrimesCache.IS_PRIME or PrimesCache.IS_NOT_PRIME or PrimesCache.NOT_IN_CACHE
-
isInitSuccessful
public boolean isInitSuccessful()Returns true in case when primes cache initialization was successful, otherwise returns false.- Returns:
- Returns true in case when primes cache initialization was successful, otherwise returns false.
-