-
Notifications
You must be signed in to change notification settings - Fork 5
Grid
Martin Hartl edited this page Jan 3, 2018
·
6 revisions
Defined in header "allscale/api/user/data/grid.h"
template<typename T, std::size_t Dims = 2>
class Grid;The Grid data structure represents a regular n-dimensional array of values, with a statically-fixed number of dimensions, and a size to be defined at creation.
| Member type | Definition |
|---|---|
coordinate_type |
GridPoint<Dims> |
region_type |
GridRegion<Dims> |
| Member function | Description |
|---|---|
Grid(const coordinate_type& size) |
Constructs a Grid of the given size |
Grid(Grid&&) |
Move constructor |
Grid& operator=(Grid&&) |
Move assignment operator |
coordinate_type size() const |
Returns the size of the Grid
|
T& operator[](const coordinate_type& index) |
Mutable read/write access operator |
const T& operator[](const coordinate_type& index) const |
Immutable read/write access operator |
template<typename Op>void forEach(const Op& op) const
|
Sequential scan through all elements of the Grid with immutable element access |
template<typename Op>void forEach(const Op& op)
|
Sequential scan through all elements of the Grid with mutable element access |
template<typename Op>auto pforEach(const Op& op) const
|
Parallel scan through all elements of the Grid with immutable element access |
template<typename Op>auto pforEach(const Op& op)
|
Parallel scan through all elements of the Grid with mutable element access |
#include <allscale/api/user/data/grid.h>
using namespace allscale::api::user::data;
// create a two-dimensional grid of integers of size 10x20
Grid<int,2> grid({10,20});
// initialize all elements with 1.0
grid.pforEach([](int& element) { element = 1.0; });
// set element at position [7,9] to 5.0
grid[{7,9}] = 5.0;Part of the AllScale project - http://www.allscale.eu