A fair partition of an integer. More...
#include "defs.h"#include <algorithm>#include <cassert>Go to the source code of this file.
| Functions | |
| BEGIN_NAMESPACE_NUMERICAL int | partition (const int x, const int n, const int i) | 
| Return the i_th fair partition of x into n parts. | |
| void | partitionRange (const int x, const int n, const int i, int *a, int *b) | 
| Compute the i_th fair partition range of x into n ranges. | |
A fair partition of an integer.
| BEGIN_NAMESPACE_NUMERICAL int partition | ( | const int | x, | |
| const int | n, | |||
| const int | i | |||
| ) |  [inline] | 
Return the i_th fair partition of x into n parts.
Partition x into n fair parts. Return the i_th part. The parts differ by at most one and are in non-increasing order.
| x | is the number to partition. | |
| n | is the number of partitions. | |
| i | is the requested partition. | 
x is non-negative. n is positive. i is in the range [0..n). Referenced by partitionRange().
| void partitionRange | ( | const int | x, | |
| const int | n, | |||
| const int | i, | |||
| int * | a, | |||
| int * | b | |||
| ) |  [inline] | 
Compute the i_th fair partition range of x into n ranges.
Partition x into n fair ranges. Compute the i_th range. The lengths of the ranges differ by at most one and are in non-increasing order.
| x | is the number to partition. | |
| n | is the number of partitions. | |
| i | is the requested range. | |
| a | is the begining of the range. | |
| b | is the end of the open range, [a..b). | 
x is non-negative. n is positive. i is in the range [0..n). References min(), and partition().
 1.6.3
 1.6.3