/
eratosthenes.hpp
41 lines (34 loc) · 1.03 KB
/
eratosthenes.hpp
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
#ifndef ERATOSTHENES_HPP_INCLUDED
#define ERATOSTHENES_HPP_INCLUDED
#include <ostream>
#include <vector>
#include <utility>
#include <iostream>
#include <chrono>
namespace voidhoge{
class null_stream : public std::streambuf, public std::ostream {
char buf_[128];
protected:
virtual int overflow(int c) {
// // std::cout << "overflow( " << c << " )" << std::endl;
setp( buf_, buf_ + sizeof( buf_ ) );
return ( c == eof() ? '\0' : c );
}
public:
null_stream() : std::ostream(this) {}
};
class prime_binary_array {
private:
std::vector<std::vector<bool>> data;
std::vector<int> base_sieve;
long long sieve_max;
public:
prime_binary_array (){};
std::pair<long long, bool> at(const size_t base_pos, const size_t line_pos) const;
size_t get_base_size() const;
size_t get_line_size() const;
long long eratosthenes_multithread(const long long limit, const int base_sieve_size, std::ostream& debug);
void dump(const long long start, const long long end, const std::string separator, std::ostream& ost);
};
} //namespace voidhoge
#endif