|
Jet
v1.3.3
|
1-D array class. More...
#include <jet/array1.h>
Public Types | |
| typedef std::vector< T > | ContainerType |
| typedef ContainerType::iterator | Iterator |
| typedef ContainerType::const_iterator | ConstIterator |
Public Member Functions | |
| Array () | |
| Constructs zero-sized 1-D array. More... | |
| Array (size_t size, const T &initVal=T()) | |
| Array (const std::initializer_list< T > &lst) | |
Constructs 1-D array with given initializer list lst. More... | |
| Array (const Array &other) | |
| Copy constructor. More... | |
| Array (Array &&other) | |
| Move constructor. More... | |
| void | set (const T &value) |
Sets entire array with given value. More... | |
| void | set (const Array &other) |
Copies given array other to this array. More... | |
| void | set (const std::initializer_list< T > &lst) |
Copies given initializer list lst to this array. More... | |
| void | clear () |
| Clears the array and resizes to zero. More... | |
| void | resize (size_t size, const T &initVal=T()) |
Resizes the array with size and fill the new element with initVal. More... | |
| T & | at (size_t i) |
| Returns the reference to the i-th element. More... | |
| const T & | at (size_t i) const |
| Returns the const reference to the i-th element. More... | |
| size_t | size () const |
| Returns size of the array. More... | |
| T * | data () |
| Returns the raw pointer to the array data. More... | |
| const T *const | data () const |
| Returns the const raw pointer to the array data. More... | |
| Iterator | begin () |
| Returns the begin iterator of the array. More... | |
| ConstIterator | begin () const |
| Returns the begin const iterator of the array. More... | |
| Iterator | end () |
| Returns the end iterator of the array. More... | |
| ConstIterator | end () const |
| Returns the end const iterator of the array. More... | |
| ArrayAccessor1< T > | accessor () |
| Returns the array accessor. More... | |
| ConstArrayAccessor1< T > | constAccessor () const |
| Returns the const array accessor. More... | |
| void | swap (Array &other) |
Swaps the content of the array with other array. More... | |
| void | append (const T &newVal) |
Appends single value newVal at the end of the array. More... | |
| void | append (const Array &other) |
Appends other array at the end of the array. More... | |
| template<typename Callback > | |
| void | forEach (Callback func) const |
Iterates the array and invoke given func for each element. More... | |
| template<typename Callback > | |
| void | forEachIndex (Callback func) const |
Iterates the array and invoke given func for each index. More... | |
| template<typename Callback > | |
| void | parallelForEach (Callback func) |
Iterates the array and invoke given func for each element in parallel using multi-threading. 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... | |
| T & | operator[] (size_t i) |
| Returns the reference to i-th element. More... | |
| const T & | operator[] (size_t i) const |
| Returns the const reference to i-th element. More... | |
| Array & | operator= (const T &other) |
Sets entire array with given value. More... | |
| Array & | operator= (const Array &other) |
Copies given array other to this array. More... | |
| Array & | operator= (Array &&other) |
| Move assignment. More... | |
| Array & | operator= (const std::initializer_list< T > &lst) |
Copies given initializer list lst to this array. More... | |
| operator ArrayAccessor1< T > () | |
| Casts to array accessor. More... | |
| operator ConstArrayAccessor1< T > () const | |
| Casts to const array accessor. More... | |
1-D array class.
This class represents 1-D array data structure. This class is a simple wrapper around std::vector with some additional features such as the array accessor object and parallel for-loop.
| T | - Type to store in the array. |
| typedef ContainerType::const_iterator jet::Array< T, 1 >::ConstIterator |
| typedef std::vector<T> jet::Array< T, 1 >::ContainerType |
| typedef ContainerType::iterator jet::Array< T, 1 >::Iterator |
| jet::Array< T, 1 >::Array | ( | ) |
Constructs zero-sized 1-D array.
|
explicit |
Constructs 1-D array with given size and fill it with initVal.
| size | Initial size of the array. |
| initVal | Initial value of each array element. |
| jet::Array< T, 1 >::Array | ( | const std::initializer_list< T > & | lst | ) |
Constructs 1-D array with given initializer list lst.
This constructor will build 1-D array with given initializer list lst such as
| lst | Initializer list that should be copy to the new array. |
| jet::Array< T, 1 >::Array | ( | const Array< T, 1 > & | other | ) |
Copy constructor.
| jet::Array< T, 1 >::Array | ( | Array< T, 1 > && | other | ) |
Move constructor.
| ArrayAccessor1<T> jet::Array< T, 1 >::accessor | ( | ) |
Returns the array accessor.
| void jet::Array< T, 1 >::append | ( | const Array< T, 1 > & | other | ) |
Appends other array at the end of the array.
| void jet::Array< T, 1 >::append | ( | const T & | newVal | ) |
Appends single value newVal at the end of the array.
| T& jet::Array< T, 1 >::at | ( | size_t | i | ) |
Returns the reference to the i-th element.
| const T& jet::Array< T, 1 >::at | ( | size_t | i | ) | const |
Returns the const reference to the i-th element.
| Iterator jet::Array< T, 1 >::begin | ( | ) |
Returns the begin iterator of the array.
| ConstIterator jet::Array< T, 1 >::begin | ( | ) | const |
Returns the begin const iterator of the array.
| void jet::Array< T, 1 >::clear | ( | ) |
Clears the array and resizes to zero.
| ConstArrayAccessor1<T> jet::Array< T, 1 >::constAccessor | ( | ) | const |
Returns the const array accessor.
| T* jet::Array< T, 1 >::data | ( | ) |
Returns the raw pointer to the array data.
| const T* const jet::Array< T, 1 >::data | ( | ) | const |
Returns the const raw pointer to the array data.
| Iterator jet::Array< T, 1 >::end | ( | ) |
Returns the end iterator of the array.
| ConstIterator jet::Array< T, 1 >::end | ( | ) | const |
Returns the end const iterator of the array.
| void jet::Array< T, 1 >::forEach | ( | Callback | func | ) | const |
Iterates the array and invoke given func for each element.
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 0 to N-1 where N is the size of the array. Below is the sample usage:
| void jet::Array< T, 1 >::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 one parameter which is the index of the array. The order of execution will be 0 to N-1 where N is the size of the array. Below is the sample usage:
| jet::Array< T, 1 >::operator ArrayAccessor1< T > | ( | ) |
Casts to array accessor.
| jet::Array< T, 1 >::operator ConstArrayAccessor1< T > | ( | ) | const |
Casts to const array accessor.
| Array& jet::Array< T, 1 >::operator= | ( | Array< T, 1 > && | other | ) |
Move assignment.
| Array& jet::Array< T, 1 >::operator= | ( | const Array< T, 1 > & | other | ) |
Copies given array other to this array.
| Array& jet::Array< T, 1 >::operator= | ( | const std::initializer_list< T > & | lst | ) |
Copies given initializer list lst to this array.
| Array& jet::Array< T, 1 >::operator= | ( | const T & | other | ) |
Sets entire array with given value.
| T& jet::Array< T, 1 >::operator[] | ( | size_t | i | ) |
Returns the reference to i-th element.
| const T& jet::Array< T, 1 >::operator[] | ( | size_t | i | ) | const |
Returns the const reference to i-th element.
| void jet::Array< T, 1 >::parallelForEach | ( | Callback | func | ) |
Iterates the array and invoke given func for each element 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 array's element as its input. The order of execution will be non-deterministic since it runs in parallel. Below is the sample usage:
The parameter type of the callback function doesn't have to be T&, but const T& or T can be used as well.
| void jet::Array< T, 1 >::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 one parameter which is the index of the array. The order of execution will be non-deterministic since it runs in parallel. Below is the sample usage:
| void jet::Array< T, 1 >::resize | ( | size_t | size, |
| const T & | initVal = T() |
||
| ) |
Resizes the array with size and fill the new element with initVal.
| void jet::Array< T, 1 >::set | ( | const Array< T, 1 > & | other | ) |
Copies given array other to this array.
| void jet::Array< T, 1 >::set | ( | const std::initializer_list< T > & | lst | ) |
Copies given initializer list lst to this array.
| void jet::Array< T, 1 >::set | ( | const T & | value | ) |
Sets entire array with given value.
| size_t jet::Array< T, 1 >::size | ( | ) | const |
Returns size of the array.
| void jet::Array< T, 1 >::swap | ( | Array< T, 1 > & | other | ) |
Swaps the content of the array with other array.
1.8.18