carl  24.04
Computer ARithmetic Library
carl::PrimeFactory< T > Class Template Reference

This class provides a convenient way to enumerate primes. More...

#include <PrimeFactory.h>

Inheritance diagram for carl::PrimeFactory< T >:

Public Member Functions

std::size_t size () const
 Returns the number of already computed primes. More...
 
const T & operator[] (std::size_t id) const
 Provides const access to the computed primes. Asserts that id is smaller than size(). More...
 
const T & operator[] (std::size_t id)
 Provides access to the computed primes. If id is at least size(), the missing primes are computed on-the-fly. More...
 
const T & next_prime ()
 Computed the next prime and returns it. More...
 

Private Attributes

std::size_t mNext = 0
 

Static Private Attributes

static std::vector< T > mPrimes
 

Detailed Description

template<typename T>
class carl::PrimeFactory< T >

This class provides a convenient way to enumerate primes.

Definition at line 13 of file PrimeFactory.h.

Member Function Documentation

◆ next_prime()

template<typename T >
const T & carl::PrimeFactory< T >::next_prime

Computed the next prime and returns it.

Definition at line 74 of file PrimeFactory.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator[]() [1/2]

template<typename T >
const T& carl::PrimeFactory< T >::operator[] ( std::size_t  id)
inline

Provides access to the computed primes. If id is at least size(), the missing primes are computed on-the-fly.

Definition at line 31 of file PrimeFactory.h.

Here is the call graph for this function:

◆ operator[]() [2/2]

template<typename T >
const T& carl::PrimeFactory< T >::operator[] ( std::size_t  id) const
inline

Provides const access to the computed primes. Asserts that id is smaller than size().

Definition at line 26 of file PrimeFactory.h.

◆ size()

template<typename T >
std::size_t carl::PrimeFactory< T >::size ( ) const
inline

Returns the number of already computed primes.

Definition at line 22 of file PrimeFactory.h.

Here is the caller graph for this function:

Field Documentation

◆ mNext

template<typename T >
std::size_t carl::PrimeFactory< T >::mNext = 0
private

Definition at line 19 of file PrimeFactory.h.

◆ mPrimes

template<typename T >
std::vector< T > carl::PrimeFactory< T >::mPrimes
staticprivate
Initial value:
= {
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
}

Definition at line 15 of file PrimeFactory.h.


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