-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_primes.h
32 lines (25 loc) · 914 Bytes
/
compute_primes.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
// compute_primes.h
// This is the class-based solution
#include <set>
class compute_primes
{
public:
compute_primes();
std::set<int> operator()(int N);
// I will not bother to implement the following
// functions b/c I see no use for them.
// Because this class has no state there's no point in
// say, copying an instance.
compute_primes(const compute_primes& cpc) = delete; // copy ctor
compute_primes operator=(const compute_primes& cpc) = delete; // copy assignment operator
compute_primes( compute_primes&& cpc) = delete; // move ctor
compute_primes operator=( compute_primes&& cpc) = delete; // move assignment operator
private:
void compute_non_primes(int factor, int limit );
int sequence();
int get_next_prime();
std::set<int> series;
std::set<int> non_prime;
int last_factor;
int last_sequence;
};