1:  package de.luschny.math.primes;
   2:   
   3:  import de.luschny.math.util.ILoggable;
   4:  import de.luschny.math.util.PositiveRange;
   5:   
   6:  /**
   7:   * An interface for a prime number sieve.
   8:   * 
   9:   * @author Peter Luschny
  10:   * @version 2004-09-12
  11:   */
  12:   
  13:  public interface IPrimeSieve extends ILoggable
  14:  {
  15:   
  16:      /**
  17:       * Checks if a given number is prime.
  18:       * 
  19:       * @param i
  20:       *            The number the primality of which is to be checked.
  21:       * @return True if the given number is prime, false otherwise.
  22:       */
  23:   
  24:      boolean isPrime(int i);
  25:   
  26:      /**
  27:       * Get the n-th prime number. (The first prime number is 2, the second 3,
  28:       * the third 5, ...)
  29:       * 
  30:       * @param n
  31:       *            The index of the prime number searched.
  32:       * @return The n-th prime number.
  33:       */
  34:   
  35:      int getNthPrime(int n);
  36:   
  37:      /**
  38:       * The default iteration of the full sieve. Thus it gives the iteration of
  39:       * the prime numbers in the range [1, n], where n is the upper bound of the
  40:       * sieve, which is an argument to the constructor of the sieve.
  41:       * 
  42:       * @return An iteration of the prime numbers in the range of the sieve.
  43:       */
  44:   
  45:      IPrimeIteration getIteration();
  46:   
  47:      /**
  48:       * Gives the iteration of the prime numbers in the range [low, high].
  49:       * <p/>
  50:       * Note: If the range is not in the range of the sieve, the function throws
  51:       * an IllegalArgumentException.
  52:       * 
  53:       * @param low
  54:       *            The lower bound of the range to be sieved.
  55:       * @param high
  56:       *            The upper bound of the range to be sieved.
  57:       * @return An iteration of the prime numbers in the range [low, high].
  58:       */
  59:   
  60:      IPrimeIteration getIteration(int low, int high);
  61:   
  62:      /**
  63:       * Gives the iteration of the prime numbers in the given range.
  64:       * <p/>
  65:       * Note: If the range is not in the range of the sieve, the function throws
  66:       * an IllegalArgumentException.
  67:       * 
  68:       * @param range
  69:       *            The range of integers to be sieved.
  70:       * @return An iteration of the prime numbers over the given range.
  71:       */
  72:   
  73:      IPrimeIteration getIteration(PositiveRange range);
  74:  }