Template Class primes

Inheritance Relationships

Base Type

Class Documentation

template<typename PRIMES_IMPLEMENTATION = euler_sieve_sqrt>
class primes : public madlib::euler_sieve_sqrt

Universal interface for easy use of essential primes operations, some types of optimization hints, and ease of use functionality.

Public Types

using value_type = prime_type

Cloned from madlib::prime_type.

using iterator = primes_iterator<PRIMES_IMPLEMENTATION>

Primes’ iterator type.

using const_iterator = const iterator

Primes’ constant iterator type.

using difference_type = typename primes_iterator<PRIMES_IMPLEMENTATION>::difference_type

Primes’ difference type used for distance between primes. Defined as primes_iterator::difference_type .

Public Functions

inline primes()

Just default initialize members.

inline explicit primes(const unsigned_integral auto &initially_through)

Construct primes object pre-calculating at least through initially_through.

inline explicit primes(const signed_integral auto &initially_through)

Construct primes object pre-calculating at least through initially_through.

inline primes<PRIMES_IMPLEMENTATION> &calculate_primes_through(const unsigned_integral auto &through_value)

Ensure primes in [0,through_value) are calculated. This can allow implementations to work more efficiently.

inline primes<PRIMES_IMPLEMENTATION> &calculate_primes_through(const signed_integral auto &through_value)

Ensure primes in [0,through_value) are calculated. This can allow implementations to work more efficiently.

inline bool is_prime(const unsigned_integral auto &number)

Derermine if number is prime or not.

inline bool is_prime(const signed_integral auto &number)

Derermine if number is prime or not.

inline prime_type get_nth_prime(const unsigned_integral auto &n)

Retrieve the nth prime, expanding mapped primes if needed.

inline void auto_expand_mapped_primes()

Implementation defined behavior, but it is a hint to map more primes.

inline void map_next_prime()

Maps the next prime known. Characteristics are implemementation defined.

inline size_t number_of_mapped_primes()

Returns the number of primes known currently by the implementation instance.

inline prime_type highest_odd_number_mapped()

Returns the highest odd number mapped in the search for primes.

inline primes_iterator<PRIMES_IMPLEMENTATION> begin()

Iterator pointing to the first prime.

inline primes_iterator<PRIMES_IMPLEMENTATION> cbegin() const

Constant iterator pointing to the first prime.

Public Static Functions

static inline constexpr primes_iterator_sentinel_t end()

Special end sentinel to represent the never reachable end of primes.