1 ///
2 /// @file  PrintPrimes.hpp
3 ///
4 /// Copyright (C) 2019 Kim Walisch, <kim.walisch@gmail.com>
5 ///
6 /// This file is distributed under the BSD License. See the COPYING
7 /// file in the top level directory.
8 ///
9 
10 #ifndef PRINTPRIMES_HPP
11 #define PRINTPRIMES_HPP
12 
13 #include "Erat.hpp"
14 #include "macros.hpp"
15 #include "PrimeSieve.hpp"
16 
17 #include <stdint.h>
18 #include <vector>
19 
20 namespace primesieve {
21 
22 class Store;
23 
24 /// After a segment has been sieved PrintPrimes is
25 /// used to reconstruct primes and prime k-tuplets from
26 /// 1 bits of the sieve array
27 ///
28 class PrintPrimes : public Erat
29 {
30 public:
31   PrintPrimes(PrimeSieve&);
32   NOINLINE void sieve();
33 private:
34   uint64_t low_ = 0;
35   /// Count lookup tables for prime k-tuplets
36   std::vector<uint8_t> kCounts_[6];
37   counts_t& counts_;
38   /// Reference to the associated PrimeSieve object
39   PrimeSieve& ps_;
40   void initCounts();
41   void print();
42   void countPrimes();
43   void countkTuplets();
44   void printPrimes() const;
45   void printkTuplets() const;
46 };
47 
48 } // namespace
49 
50 #endif
51