1:
2: namespace Luschny.Math.Primes
3: {
4: using Luschny.Math.MathUtils;
5:
6: /// <summary>
7: /// The interface for a prime number sieve.
8: /// Much of its functionality is given through PrimeCollections.
9: ///
10: /// @version cs-2004-09-02
11: /// @author Peter Luschny
12: /// </summary>
13: public interface IPrimeSieve
14: {
15: /// <summary>
16: /// Checks if a given number is prime.
17: /// </summary>
18: /// <param name="cand">The number the primality of which is
19: /// to be checked.</param>
20: /// <returns>True iff the given number is prime.</returns>
21: bool IsPrime(int cand);
22:
23: /// <summary>
24: /// Gets the n-th prime number.
25: /// </summary>
26: /// <param name="n">The index of the prime number.</param>
27: /// <returns>The n-th prime number.</returns>
28: int GetNthPrime(int n);
29:
30: /// <summary>
31: /// Returns the default PrimeCollection of the full sieve.
32: /// In other words: This PrimeCollection includes all
33: /// prime numbers p, such that 1 <= p <= high, where
34: /// high is the upper bound of the under laying sieve.
35: /// </summary>
36: /// <returns>The enumeration of the sieve.</returns>
37: IPrimeCollection GetPrimeCollection();
38:
39: /// <summary>
40: /// Gives the PrimeCollection of a subrange of the sieve.
41: /// It is the collection of all prime numbers p,
42: /// such that low <= p <= high.
43: /// Note: If the range [low, high] is not included in the range
44: /// of the sieve, this function might throw an ArgumentOutOfRangeException.
45: /// </summary>
46: /// <param name="low">The low limit of the enumaration interval.</param>
47: /// <param name="high">The high limit of the enumeration interval.</param>
48: /// <returns>The enumeration of the prime numbers between
49: /// low and high.</returns>
50: IPrimeCollection GetPrimeCollection(int low, int high);
51:
52: /// <summary>
53: /// Gives the PrimeCollection of a subrange of the sieve.
54: /// It is the collection of all prime numbers p,
55: /// such that 0 < range.low <= p <= range.high.
56: /// Note: If the range is not included in the range of the sieve,
57: /// this function might throw an ArgumentOutOfRangeException.
58: /// </summary>
59: /// <param name="range">The range of the enumeration.</param>
60: /// <returns>The enumeration of the prime numbers in
61: /// the given range.</returns>
62: IPrimeCollection GetPrimeCollection(PositiveRange range);
63: }
64: }