Jet
v1.3.3
|
2-D read-only array accessor class. More...
#include <jet/array_accessor2.h>
Public Member Functions | |
ConstArrayAccessor () | |
Constructs empty 2-D read-only array accessor. More... | |
ConstArrayAccessor (const Size2 &size, const T *const data) | |
ConstArrayAccessor (size_t width, size_t height, const T *const data) | |
ConstArrayAccessor (const ArrayAccessor< T, 2 > &other) | |
Constructs a read-only array accessor from read/write accessor. More... | |
ConstArrayAccessor (const ConstArrayAccessor &other) | |
Copy constructor. More... | |
const T & | at (size_t i) const |
Returns the reference to the i-th element. More... | |
const T & | at (const Point2UI &pt) const |
Returns the const reference to the element at (pt.x, pt.y). More... | |
const T & | at (size_t i, size_t j) const |
Returns the const reference to the element at (i, j). More... | |
const T *const | begin () const |
Returns the begin iterator of the array. More... | |
const T *const | end () const |
Returns the end iterator of the array. More... | |
Size2 | size () const |
Returns the size of the array. More... | |
size_t | width () const |
Returns the width of the array. More... | |
size_t | height () const |
Returns the height of the array. More... | |
const T *const | data () const |
Returns the raw pointer to the array data. More... | |
template<typename Callback > | |
void | forEach (Callback func) const |
Iterates the array and invoke given func for each index. More... | |
template<typename Callback > | |
void | forEachIndex (Callback func) const |
Iterates the array and invoke given func for each index. More... | |
template<typename Callback > | |
void | parallelForEachIndex (Callback func) const |
Iterates the array and invoke given func for each index in parallel using multi-threading. More... | |
size_t | index (const Point2UI &pt) const |
Returns the linear index of the given 2-D coordinate (pt.x, pt.y). More... | |
size_t | index (size_t i, size_t j) const |
Returns the linear index of the given 2-D coordinate (i, j). More... | |
const T & | operator[] (size_t i) const |
Returns the const reference to the i-th element. More... | |
const T & | operator() (const Point2UI &pt) const |
Returns the const reference to the element at (pt.x, pt.y). More... | |
const T & | operator() (size_t i, size_t j) const |
Returns the const reference to the element at (i, j). More... | |
2-D read-only array accessor class.
This class represents 2-D read-only array accessor. Array accessor provides array-like data read/write functions, but does not handle memory management. Thus, it is more like a random access iterator, but with multi-dimension support. Similar to Array2<T, 2>, this class interprets a linear array as a 2-D array using i-major indexing.
jet::ConstArrayAccessor< T, 2 >::ConstArrayAccessor | ( | ) |
Constructs empty 2-D read-only array accessor.
jet::ConstArrayAccessor< T, 2 >::ConstArrayAccessor | ( | const Size2 & | size, |
const T *const | data | ||
) |
Constructs a read-only array accessor that wraps given array.
size | Size of the 2-D array. |
data | Raw array pointer. |
jet::ConstArrayAccessor< T, 2 >::ConstArrayAccessor | ( | size_t | width, |
size_t | height, | ||
const T *const | data | ||
) |
Constructs an array accessor that wraps given array.
width | Width of the 2-D array. |
height | Height of the 2-D array. |
data | Raw array pointer. |
|
explicit |
Constructs a read-only array accessor from read/write accessor.
jet::ConstArrayAccessor< T, 2 >::ConstArrayAccessor | ( | const ConstArrayAccessor< T, 2 > & | other | ) |
Copy constructor.
const T& jet::ConstArrayAccessor< T, 2 >::at | ( | const Point2UI & | pt | ) | const |
Returns the const reference to the element at (pt.x, pt.y).
const T& jet::ConstArrayAccessor< T, 2 >::at | ( | size_t | i | ) | const |
Returns the reference to the i-th element.
const T& jet::ConstArrayAccessor< T, 2 >::at | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the const reference to the element at (i, j).
const T* const jet::ConstArrayAccessor< T, 2 >::begin | ( | ) | const |
Returns the begin iterator of the array.
const T* const jet::ConstArrayAccessor< T, 2 >::data | ( | ) | const |
Returns the raw pointer to the array data.
const T* const jet::ConstArrayAccessor< T, 2 >::end | ( | ) | const |
Returns the end iterator of the array.
void jet::ConstArrayAccessor< T, 2 >::forEach | ( | Callback | func | ) | const |
Iterates the array and invoke given func
for each index.
This function iterates the array elements and invoke the callback function func
. The callback function takes array's element as its input. The order of execution will be the same as the nested for-loop below:
Below is the sample usage:
void jet::ConstArrayAccessor< T, 2 >::forEachIndex | ( | Callback | func | ) | const |
Iterates the array and invoke given func
for each index.
This function iterates the array elements and invoke the callback function func
. The callback function takes two parameters which are the (i, j) indices of the array. The order of execution will be the same as the nested for-loop below:
Below is the sample usage:
size_t jet::ConstArrayAccessor< T, 2 >::height | ( | ) | const |
Returns the height of the array.
size_t jet::ConstArrayAccessor< T, 2 >::index | ( | const Point2UI & | pt | ) | const |
Returns the linear index of the given 2-D coordinate (pt.x, pt.y).
size_t jet::ConstArrayAccessor< T, 2 >::index | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the linear index of the given 2-D coordinate (i, j).
const T& jet::ConstArrayAccessor< T, 2 >::operator() | ( | const Point2UI & | pt | ) | const |
Returns the const reference to the element at (pt.x, pt.y).
const T& jet::ConstArrayAccessor< T, 2 >::operator() | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the const reference to the element at (i, j).
const T& jet::ConstArrayAccessor< T, 2 >::operator[] | ( | size_t | i | ) | const |
Returns the const reference to the i-th element.
void jet::ConstArrayAccessor< T, 2 >::parallelForEachIndex | ( | Callback | func | ) | const |
Iterates the array and invoke given func
for each index in parallel using multi-threading.
This function iterates the array elements and invoke the callback function func
in parallel using multi-threading. The callback function takes two parameters which are the (i, j) indices of the array. The order of execution will be non-deterministic since it runs in parallel. Below is the sample usage:
Size2 jet::ConstArrayAccessor< T, 2 >::size | ( | ) | const |
Returns the size of the array.
size_t jet::ConstArrayAccessor< T, 2 >::width | ( | ) | const |
Returns the width of the array.