#include <Combinations.hpp>
Let n 'things' be indexed by i (i=0...n-1), e.g. stored in an array of length n. This class computes C(n,k) as sets of k indexes into the 'things' array. These indexes are accessible via member functions Selection() or isSelected(). Next() computes the next combination until there are no more (when it returns -1).
Definition at line 675 of file Combinations.hpp.
Public Member Functions | ||||
| Combinations (void) throw () | ||||
| Default constructor. | ||||
| Combinations (int N, int K) throw (Exception) | ||||
Constructor for C(n,k) = combinations of n things taken k at a time (k <= n)
| ||||
| Combinations (const Combinations &right) throw () | ||||
| copy constructor | ||||
| Combinations & | operator= (const Combinations &right) throw () | |||
| Assignment operator. | ||||
| int | Next (void) throw () | |||
| Compute the next combination, returning the number of combinations computed so far; if there are no more combinations, return -1. | ||||
| int | Selection (int j) throw () | |||
| Return index i (0 <= i < n) of jth selection (0 <= j < k); if j is out of range, return -1. | ||||
| bool | isSelected (int j) throw () | |||
| Return true if the given index j (0 <= j < n) is currently selected (i.e. | ||||
|
|
Default constructor.
Definition at line 678 of file Combinations.hpp. |
|
||||||||||||
|
Constructor for C(n,k) = combinations of n things taken k at a time (k <= n)
Definition at line 686 of file Combinations.hpp. |
|
|
copy constructor
Definition at line 690 of file Combinations.hpp. |
|
|
Return true if the given index j (0 <= j < n) is currently selected (i.e. if j = Selection(i) for some i) Definition at line 723 of file Combinations.hpp. Referenced by PRSolution2::RAIMCompute(), and PRSolution::RAIMCompute(). |
|
|
Compute the next combination, returning the number of combinations computed so far; if there are no more combinations, return -1.
Definition at line 707 of file Combinations.hpp. Referenced by PRSolution2::RAIMCompute(), and PRSolution::RAIMCompute(). |
|
|
Assignment operator.
Definition at line 697 of file Combinations.hpp. |
|
|
Return index i (0 <= i < n) of jth selection (0 <= j < k); if j is out of range, return -1.
Definition at line 715 of file Combinations.hpp. |
1.3.9.1