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. More... | |
multifor (const std::vector< size_t > &d) | |
Initialize from vector of index ranges. More... | |
operator size_t () const | |
Returns linear index (i.e., the index in the Cartesian product space) More... | |
size_t | operator[] (size_t k) const |
Returns k 'th index. More... | |
multifor & | operator++ () |
Increments the current indices (prefix) More... | |
void | operator++ (int) |
Increments the current indices (postfix) More... | |
multifor & | reset () |
Resets the state. More... | |
bool | valid () const |
Returns true if the current indices are valid. More... | |
Private Attributes | |
std::vector< size_t > | _ranges |
Stores the number of possible values of all indices. More... | |
std::vector< size_t > | _indices |
Stores the current values of all indices. More... | |
long | _linear_index |
Stores the current linear index. More... | |
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.