Project Euler Solutions
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
c::include::primes::prime_counter Struct Reference

A cached prime number generator. More...

#include <primes.h>

Inheritance diagram for c::include::primes::prime_counter:
Inheritance graph
[legend]
Collaboration diagram for c::include::primes::prime_counter:
Collaboration graph
[legend]

Public Member Functions

prime_counter prime_counter1 (uintmax_t stop)
 The base constructor for the prime number generator. More...
 
prime_counter prime_counter0 ()
 The simplest constructor for the prime number generator. More...
 

Public Attributes

size_t idx
 The current position of the counter. More...
 
uintmax_t stop
 The point where the counter is exhausted. More...
 
prime_sieveps
 A (currently unused) source for new prime numbers. More...
 
- Public Attributes inherited from c::include::iterator::Iterator
bool exhausted: 1
 An indicator that the iterator has stopped. More...
 
bool started: 1
 An indicator that the iterator has started. More...
 
bool phase: 1
 An indicator that changes each time the iterator moves. More...
 

Private Member Functions

void free_prime_counter (prime_counter *pc)
 The destructor for the prime number counter. More...
 
uintmax_t advance_prime_counter (prime_counter *pc)
 The function to advance a prime number generator. More...
 

Private Attributes

uintmax_t(*const iterator_function )(prime_counter *it)
 The pointer to the iteration function. More...
 
void(*const destructor )(void *it)
 The pointer to the destructor function. More...
 

Additional Inherited Members

Detailed Description

A cached prime number generator.

Note
If you will only use the prime numbers once in your program, use prime_sieve instead

Member Function Documentation

uintmax_t advance_prime_counter ( prime_counter pc)
private

The function to advance a prime number generator.

Parameters
pcthe counter you want to advance
Returns
the next number in the iteration

Here is the call graph for this function:

Here is the caller graph for this function:

void free_prime_counter ( prime_counter pc)
private

The destructor for the prime number counter.

Here is the caller graph for this function:

prime_counter prime_counter0 ( )

The simplest constructor for the prime number generator.

Here is the caller graph for this function:

prime_counter prime_counter1 ( uintmax_t  stop)

The base constructor for the prime number generator.

Parameters
stopThe point where the counter is exhausted

Here is the caller graph for this function:

Member Data Documentation

void(*const c::include::primes::prime_counter::destructor) (void *it)
private

The pointer to the destructor function.

See also
free_iterator
size_t c::include::primes::prime_counter::idx

The current position of the counter.

uintmax_t(*const c::include::primes::prime_counter::iterator_function) (prime_counter *it)
private

The pointer to the iteration function.

See also
next
prime_sieve* c::include::primes::prime_counter::ps

A (currently unused) source for new prime numbers.

uintmax_t c::include::primes::prime_counter::stop

The point where the counter is exhausted.


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