#include <utils.h>
Public Member Functions | |
| SumDecompositions (size_t sum, size_t addends) | |
| Initializes decompositions tables up to maximum `sum` and maximum number of `addends`. | |
| ~SumDecompositions (void) | |
| Deletes all dynamically allocated memory. | |
| const sum_decompositions_t * | get_decompositions_table (size_t sum, size_t addends) |
Private Types | |
| typedef std::map< size_t, sum_decompositions_t * > | overflow_sum_decompositions_mapping_t |
Private Member Functions | |
| void | _init (void) |
| Initialization procedure. | |
| SumDecompositions (const SumDecompositions &sum_decompositions) | |
| SumDecompositions & | operator= (const SumDecompositions &sum_decompositions) |
Private Attributes | |
| size_t | _n |
| Variables to store sum (N) and number of addends (M). | |
| size_t | _m |
| sum_decompositions_t ** | _tables |
| Pointer to the beginning of array of pointers to the decompositions tables. | |
| overflow_sum_decompositions_mapping_t | _overflow |
| Map to hold the overflowed tables - tables that has one of their params bigger than corresponding param in class constructor. | |
Class stores decompositions not only for given numbers, but up to them. So for constructor parameters N = 4, M = 7 it's possible to ask for all decompositions of sum 4 into 7 addends (and one of them is: 0+0+2+0+1+1+0). Moreover it's possible to ask for all decompositions of params higher than those passed to constructor (e.g. decompositions of sum 5 into 10 addends), but this calls have slower performance, because results for them are counted at first-ask-time, not during object initialization.
typedef std::map<size_t, sum_decompositions_t*> ace::SumDecompositions::overflow_sum_decompositions_mapping_t [private] |
| ace::SumDecompositions::SumDecompositions | ( | const SumDecompositions & | sum_decompositions | ) | [private] |
| ace::SumDecompositions::SumDecompositions | ( | size_t | sum, | |
| size_t | addends | |||
| ) | [inline] |
Initializes decompositions tables up to maximum `sum` and maximum number of `addends`.
| ace::SumDecompositions::~SumDecompositions | ( | void | ) |
Deletes all dynamically allocated memory.
| void ace::SumDecompositions::_init | ( | void | ) | [private] |
Initialization procedure.
| SumDecompositions& ace::SumDecompositions::operator= | ( | const SumDecompositions & | sum_decompositions | ) | [private] |
| const sum_decompositions_t * ace::SumDecompositions::get_decompositions_table | ( | size_t | sum, | |
| size_t | addends | |||
| ) |
| sum | Determines the sum. | |
| addends | Determines the number of addends. |
size_t ace::SumDecompositions::_n [private] |
Variables to store sum (N) and number of addends (M).
size_t ace::SumDecompositions::_m [private] |
sum_decompositions_t** ace::SumDecompositions::_tables [private] |
Pointer to the beginning of array of pointers to the decompositions tables.
Map to hold the overflowed tables - tables that has one of their params bigger than corresponding param in class constructor.
1.5.6