Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
PreCalculatedPrimeTable Class Reference

#include <prime_tables.h>

Inheritance diagram for PreCalculatedPrimeTable:
Collaboration diagram for PreCalculatedPrimeTable:

Public Member Functions

 PreCalculatedPrimeTable (int max)
 
virtual ~PreCalculatedPrimeTable ()
 
virtual bool IsPrime (int n) const
 
virtual int GetNextPrime (int p) const
 
- Public Member Functions inherited from PrimeTable
virtual ~PrimeTable ()
 

Detailed Description

Definition at line 80 of file prime_tables.h.

Constructor & Destructor Documentation

◆ PreCalculatedPrimeTable()

PreCalculatedPrimeTable::PreCalculatedPrimeTable ( int max)
inlineexplicit

Definition at line 83 of file prime_tables.h.

84 : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) {
85 CalculatePrimesUpTo(max);
86 }

◆ ~PreCalculatedPrimeTable()

virtual PreCalculatedPrimeTable::~PreCalculatedPrimeTable ( )
inlinevirtual

Definition at line 87 of file prime_tables.h.

87{ delete[] is_prime_; }

Member Function Documentation

◆ GetNextPrime()

virtual int PreCalculatedPrimeTable::GetNextPrime ( int p) const
inlinevirtual

Implements PrimeTable.

Definition at line 93 of file prime_tables.h.

93 {
94 for (int n = p + 1; n < is_prime_size_; n++) {
95 if (is_prime_[n]) return n;
96 }
97
98 return -1;
99 }
const mie::Vuint & p
Definition bn.cpp:27

◆ IsPrime()

virtual bool PreCalculatedPrimeTable::IsPrime ( int n) const
inlinevirtual

Implements PrimeTable.

Definition at line 89 of file prime_tables.h.

89 {
90 return 0 <= n && n < is_prime_size_ && is_prime_[n];
91 }

The documentation for this class was generated from the following file: