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

#include <primes.h>

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

Public Member Functions

prime_factor_counter prime_factors (uintmax_t n)
 The base constructor for the prime factors iterator. More...
 

Public Attributes

uintmax_t target
 The current target for prime factorization. More...
 
uintmax_t current
 The prime number most recently tested. More...
 
prime_counter pc
 The prime number generator being used to test. 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_factor_counter (prime_factor_counter *pfc)
 The destructor for the prime factor generator. More...
 
uintmax_t advance_prime_factor_counter (prime_factor_counter *pfc)
 The function to advance a prime factor iterator. More...
 

Private Attributes

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

Related Functions

(Note that these are not member functions.)

uintmax_t is_composite (uintmax_t n)
 Tells you if a number is composite, and if so, its smallest prime factor. More...
 
bool is_prime (uintmax_t n)
 Tells you if a number is prime. More...
 

Detailed Description

The iterator that allows you to prime factorize a number

Member Function Documentation

uintmax_t advance_prime_factor_counter ( prime_factor_counter pfc)
private

The function to advance a prime factor iterator.

Parameters
ithe counter you want to advance
Returns
the next prime factor OR -1
void free_prime_factor_counter ( prime_factor_counter pfc)
private

The destructor for the prime factor generator.

prime_factor_counter prime_factors ( uintmax_t  n)

The base constructor for the prime factors iterator.

Parameters
nThe non-zero number you wish to factor
Attention
If you put in 0, behaviour is undefined

Here is the call graph for this function:

Friends And Related Function Documentation

uintmax_t is_composite ( uintmax_t  n)
related

Tells you if a number is composite, and if so, its smallest prime factor.

Parameters
nThe number you wish to test
Returns
Either 0 or the number's smallest prime factor
bool is_prime ( uintmax_t  n)
related

Tells you if a number is prime.

Parameters
nThe number you wish to test
Returns
A bool indicating whether a number is prime

Member Data Documentation

uintmax_t c::include::primes::prime_factor_counter::current

The prime number most recently tested.

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

The pointer to the destructor function.

See also
free_iterator
uintmax_t(*const c::include::primes::prime_factor_counter::iterator_function) (prime_factor_counter *it)
private

The pointer to the iteration function.

See also
next
prime_counter c::include::primes::prime_factor_counter::pc

The prime number generator being used to test.

uintmax_t c::include::primes::prime_factor_counter::target

The current target for prime factorization.

Note
this will change after construction

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