-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsieve_iterator.h
49 lines (42 loc) · 1.27 KB
/
sieve_iterator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Licensed under the MIT License.
#include "sieve.h"
/** Provides an iterator over all primes. */
struct SieveIterator
{
struct Sieve* values;
size_t index;
long long current;
};
/** Provides an iterator over all primes. */
typedef struct SieveIterator* SieveIterator;
/**
* Provides an iterator over all primes.
*
* @param iterator when this method returns, contains the iterator. This
* argument is passed uninitialized.
* @param values the sieve whose elements to enumerate. This method may
* dynamically extend the `values` argument.
*/
void sieve_begin(SieveIterator iterator, Sieve values);
/**
* Advances the iterator to the first prime greater than or equal to a given
* minimum.
*
* @param iterator the iterator.
* @param min the required minimum value.
*/
void sieve_jump(SieveIterator iterator, long long min);
/**
* Advances the iterator by a given number of primes.
*
* @param iterator the iterator.
* @param count the number of iterations to skip. This method may dynamically
* extend the `values` argument.
*/
void sieve_skip(SieveIterator iterator, size_t count);
/**
* Advances the iterator to the next prime.
*
* @param iterator the iterator.
*/
void sieve_next(SieveIterator iterator);