1:  using System.Collections.Generic;
2:  using Luschny.Math.MathUtils;
3:
4:
5:  namespace Luschny.Math.Primes
6:  {
7:       /// <summary>
8:       ///  An interface for enumerating a prime number sieve.
9:       ///
10:       ///  An IPrimeCollection is both IEnumerable&lt;int&gt;
11:       ///  and IDisposable as well as an IEnumerator&lt;int&gt;.
12:       /// <blockquote><pre>
13:       ///
14:       /// To understand the difference between "SieveRange" and "PrimeRange"
15:       /// better, let us consider the following example:
16:       ///
17:       /// If the SieveRange is 10..20, then the PrimeRange is 5..8,
18:       /// because of the following table
19:       ///
20:       ///                    &lt;-     SieveRange           -&gt;
21:       /// 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
22:       /// x,1,2,x,3,x,4,x,x, x, 5, x, 6, x, x, x, 7, x, 8, x, x, x, 9
23:       ///                    &lt;-     PrimeRange           -&gt;
24:       ///
25:       /// Thus the smallest prime in the SieveRange is the 5-th prime and
26:       /// the largest prime in this SieveRange is the 8-th prime.
27:       ///
28:       /// </pre></blockquote>
29:       ///
30:       /// version cs-2004-09-03
31:       /// author Peter Luschny
32:       ///
33:       /// </summary>
34:      public interface IPrimeCollection : IEnumerator<int>, IEnumerable<int>
35:      {
36:          /// <summary>
37:          /// Gets the number of primes in the enumeration.
38:          /// </summary>
39:          int NumberOfPrimes { get; }
40:
41:          /// <summary>
42:          /// Gets the intervall proceeded by the sieve.
43:          /// </summary>
44:          PositiveRange SieveRange { get; }
45:
46:          /// <summary>
47:          /// Gets the SieveRange of the indices of the prime numbers in the enumeration.
48:          /// </summary>
49:          PositiveRange PrimeRange { get; }
50:
51:          /// <summary>
52:          /// Returns the primes in the SieveRange under consideration
53:          /// as an array.
54:          /// </summary>
55:          /// <returns>An array of the primes in the SieveRange.</returns>
56:          int[] ToArray();
57:
58:          /// <summary>
59:          /// Writes the prime number enumeration (somewhat formatted)
60:          /// to a file.
61:          /// </summary>
62:          /// <param name="fileName">The name of the file where the
63:          /// enumeration is to be stored.</param>
64:          /// <returns>Full path of the file written to.</returns>
65:          string ToFile(string fileName);
66:      }
67:  }