de.luschny.math.primes
Interface IPrimeSieve

All Known Implementing Classes:
PrimeSieve

public interface IPrimeSieve

An interface for a prime number sieve.

Author:
Peter Luschny

Method Summary
 IPrimeCollection getCollection()
          The default collection of the full sieve.
 IPrimeCollection getCollection(int low, int high)
          Gives the collection of the prime numbers in the range [low, high].
 IPrimeCollection getCollection(PositiveRange range)
          Gives the collection of the prime numbers in the given range.
 int getNthPrime(int n)
          Get the n-th prime number.
 boolean isPrime(int i)
          Checks if a given number is prime.
 

Method Detail

getCollection

IPrimeCollection getCollection()
The default collection of the full sieve. Thus it gives the collection of the prime numbers in the range [1, n], where n is the upper bound of the sieve, which is an argument to the constructor of the sieve.

Returns:
An collection of the prime numbers in the range of the sieve.

getCollection

IPrimeCollection getCollection(int low,
                               int high)
Gives the collection of the prime numbers in the range [low, high]. Note: If the range is not in the range of the sieve, the function throws an IllegalArgumentException.

Parameters:
low - The lower bound of the range to be sieved.
high - The upper bound of the range to be sieved.
Returns:
An iteration of the prime numbers in the range [low, high].

getCollection

IPrimeCollection getCollection(PositiveRange range)
Gives the collection of the prime numbers in the given range. Note: If the range is not in the range of the sieve, the function throws an IllegalArgumentException.

Parameters:
range - The range of integers to be sieved.
Returns:
An collection of the prime numbers over the given range.

getNthPrime

int getNthPrime(int n)
Get the n-th prime number. (The first prime number is 2, the second 3, the third 5, ...)

Parameters:
n - The index of the prime number searched.
Returns:
The n-th prime number.

isPrime

boolean isPrime(int i)
Checks if a given number is prime.

Parameters:
i - The number the primelity of which is to be checked.
Returns:
True if the given number is prime, false otherwise.