MultiIndex class for iterating over multi-dimensional indices.
More...
#include <multi_index.hpp>
|
| | MultiIndex (std::array< int, D > size, std::array< int, D > offset=std::array< int, D >()) |
| | Constructs a MultiIndex object with the specified offset and size in each dimension.
|
| |
|
const std::array< int, D > & | get_begin () const |
| |
|
const std::array< int, D > & | get_size () const |
| |
|
const std::array< int, D > & | get_end () const |
| |
|
const size_t & | get_linear_begin () const |
| |
|
const size_t & | get_linear_size () const |
| |
|
const size_t & | get_linear_end () const |
| |
| size_t | to_linear (const std::array< int, D > &indices) const |
| | Converts a multi-dimensional index to its corresponding linear index.
|
| |
| std::array< int, D > | to_multi (size_t idx) const |
| | Converts a linear index to its corresponding multi-dimensional indices.
|
| |
| bool | inbounds (const std::array< int, D > &indices) const |
| | Checks whether given indices are in bounds or not.
|
| |
| Iterator | begin () |
| | Returns an iterator pointing to the beginning of the range.
|
| |
| Iterator | end () |
| | Returns an iterator pointing to the end of the range.
|
| |
| Iterator | begin () const |
| | Returns a const iterator pointing to the beginning of the range.
|
| |
| Iterator | end () const |
| | Returns a const iterator pointing to the end of the range.
|
| |
| Iterator | from (std::array< int, D > from) |
| | Returns an iterator starting from the specified multi-dimensional indices.
|
| |
| Iterator | from (size_t from) |
| | Returns an iterator starting from the specified linear index.
|
| |
template<
size_t D>
class pfc::MultiIndex< D >
MultiIndex class for iterating over multi-dimensional indices.
The MultiIndex class provides a convenient way to iterate over multi-dimensional indices. It supports iterating over a range defined by an offset and size in each dimension. The class also provides conversion functions between linear and multi-dimensional indices.
- Template Parameters
-
| D | The number of dimensions. |
- Examples
- 06_multi_index.cpp.
◆ MultiIndex()
Constructs a MultiIndex object with the specified offset and size in each dimension.
- Parameters
-
| size | The size of the range in each dimension. |
| offset | The offset of the range in each dimension (default: 0) |
◆ begin() [1/2]
Returns an iterator pointing to the beginning of the range.
- Returns
- An iterator pointing to the beginning of the range.
- Examples
- 06_multi_index.cpp.
◆ begin() [2/2]
Returns a const iterator pointing to the beginning of the range.
- Returns
- A const iterator pointing to the beginning of the range.
◆ end() [1/2]
Returns an iterator pointing to the end of the range.
- Returns
- An iterator pointing to the end of the range.
- Examples
- 06_multi_index.cpp.
◆ end() [2/2]
Returns a const iterator pointing to the end of the range.
- Returns
- A const iterator pointing to the end of the range.
◆ from() [1/2]
Returns an iterator starting from the specified linear index.
This function creates an iterator starting from the specified linear index. The linear index is converted to the corresponding multi-dimensional indices, and the iterator is constructed using these indices and the current MultiIndex object.
- Parameters
-
| from | The linear index to start from. |
- Returns
- An iterator starting from the specified linear index.
◆ from() [2/2]
Returns an iterator starting from the specified multi-dimensional indices.
- Parameters
-
| from | The multi-dimensional indices to start from. |
- Returns
- An iterator starting from the specified multi-dimensional indices.
- Examples
- 06_multi_index.cpp.
◆ inbounds()
Checks whether given indices are in bounds or not.
- Parameters
-
- Returns
- true if in bounds, false otherwise
◆ to_linear()
Converts a multi-dimensional index to its corresponding linear index.
- Parameters
-
| indices | The multi-dimensional indices. |
- Returns
- The linear index corresponding to the given indices.
◆ to_multi()
Converts a linear index to its corresponding multi-dimensional indices.
- Parameters
-
- Returns
- The multi-dimensional indices corresponding to the given linear index.
◆ operator<<
Outputs the index to the specified output stream.
- Parameters
-
| os | The output stream. |
| index | The index to output. |
- Returns
- Reference to the output stream.
The documentation for this class was generated from the following file: