libDAI
|
multifor makes it easy to perform a dynamic number of nested for
loops.
More...
#include <dai/index.h>
Public Member Functions | |
multifor () | |
Default constructor. | |
multifor (const std::vector< size_t > &d) | |
Initialize from vector of index ranges. | |
operator size_t () const | |
Returns linear index (i.e., the index in the Cartesian product space) | |
size_t | operator[] (size_t k) const |
Returns k 'th index. | |
multifor & | operator++ () |
Increments the current indices (prefix) | |
void | operator++ (int) |
Increments the current indices (postfix) | |
multifor & | reset () |
Resets the state. | |
bool | valid () const |
Returns true if the current indices are valid. |
Private Attributes | |
std::vector< size_t > | _ranges |
Stores the number of possible values of all indices. | |
std::vector< size_t > | _indices |
Stores the current values of all indices. | |
long | _linear_index |
Stores the current linear index. |
multifor makes it easy to perform a dynamic number of nested for
loops.
An example of the usage is as follows:
which would be equivalent to:
|
inline |
Default constructor.
|
inline |
Initialize from vector of index ranges.
|
inline |
Returns linear index (i.e., the index in the Cartesian product space)
|
inline |
Returns k 'th index.
|
inline |
Increments the current indices (prefix)
|
inline |
Increments the current indices (postfix)
|
inline |
Resets the state.
|
inline |
Returns true
if the current indices are valid.
|
private |
Stores the number of possible values of all indices.
|
private |
Stores the current values of all indices.
|
private |
Stores the current linear index.