Template Numerical Library version main:1655e92
|
Array with constant size. More...
#include <TNL/Containers/StaticArray.h>
Public Types | |
using | IndexType = int |
Type being used for the array elements indexing. | |
using | ValueType = Value |
Type of elements stored in this array. | |
Public Member Functions | |
__cuda_callable__ | StaticArray ()=default |
Default constructor. | |
__cuda_callable__ | StaticArray (const StaticArray< Size, Value > &v) |
Copy constructor. More... | |
__cuda_callable__ | StaticArray (const std::initializer_list< Value > &elems) |
Constructor which initializes the array by copying elements from std::initializer_list, e.g. {...} . More... | |
__cuda_callable__ | StaticArray (const Value &v) |
Constructor that sets all array components to value v. More... | |
__cuda_callable__ | StaticArray (const Value &v1, const Value &v2) |
Constructor that sets components of arrays with Size = 2. More... | |
__cuda_callable__ | StaticArray (const Value &v1, const Value &v2, const Value &v3) |
Constructor that sets components of arrays with Size = 3. More... | |
template<typename _unused = void> | |
__cuda_callable__ | StaticArray (const Value v[Size]) |
Constructor from static array. More... | |
__cuda_callable__ Value * | getData () |
Gets pointer to data of this static array. | |
__cuda_callable__ const Value * | getData () const |
Gets constant pointer to data of this static array. | |
bool | load (File &file) |
Loads data from the file to this static array. More... | |
template<typename OtherValue > | |
__cuda_callable__ | operator StaticArray< Size, OtherValue > () const |
Cast operator for changing of the Value type. More... | |
template<typename Array > | |
__cuda_callable__ bool | operator!= (const Array &array) const |
This function checks whether this static array is not equal to another array. More... | |
__cuda_callable__ Value & | operator() (int i) |
Accesses specified element at the position i and returns a reference to its value. More... | |
__cuda_callable__ const Value & | operator() (int i) const |
Accesses specified element at the position i and returns a constant reference to its value. More... | |
__cuda_callable__ StaticArray< Size, Value > & | operator= (const StaticArray< Size, Value > &array) |
Assigns another static array to this array. | |
template<typename T > | |
__cuda_callable__ StaticArray< Size, Value > & | operator= (const T &v) |
Assigns an object v of type T. More... | |
template<typename Array > | |
__cuda_callable__ bool | operator== (const Array &array) const |
This function checks whether this static array is equal to another array. More... | |
__cuda_callable__ Value & | operator[] (int i) |
Accesses specified element at the position i and returns a reference to its value. More... | |
__cuda_callable__ const Value & | operator[] (int i) const |
Accesses specified element at the position i and returns a constant reference to its value. More... | |
bool | save (File &file) const |
Saves this static array into the file. More... | |
__cuda_callable__ void | setValue (const ValueType &val) |
Sets all values of this static array to val. | |
void | sort () |
Sorts the elements in this static array in ascending order. | |
std::ostream & | write (std::ostream &str, const char *separator=" ") const |
Writes the array values into stream str with specified separator. More... | |
__cuda_callable__ Value & | x () |
Returns reference to the first coordinate. | |
__cuda_callable__ const Value & | x () const |
Returns constant reference to the first coordinate. | |
__cuda_callable__ Value & | y () |
Returns reference to the second coordinate for arrays with Size >= 2. | |
__cuda_callable__ const Value & | y () const |
Returns constant reference to the second coordinate for arrays with Size >= 2. | |
__cuda_callable__ Value & | z () |
Returns reference to the third coordinate for arrays with Size >= 3. | |
__cuda_callable__ const Value & | z () const |
Returns constant reference to the third coordinate for arrays with Size >= 3. | |
Static Public Member Functions | |
static __cuda_callable__ constexpr int | getSize () |
Gets size of this array. | |
Protected Attributes | |
Value | data [Size] |
Array with constant size.
Size | Size of static array. Number of its elements. |
Value | Type of the values in static array. |
__cuda_callable__ TNL::Containers::StaticArray< Size, Value >::StaticArray | ( | const Value | v[Size] | ) |
Constructor from static array.
v | Input array. |
__cuda_callable__ TNL::Containers::StaticArray< Size, Value >::StaticArray | ( | const Value & | v | ) |
Constructor that sets all array components to value v.
v | Reference to a value. |
__cuda_callable__ TNL::Containers::StaticArray< Size, Value >::StaticArray | ( | const StaticArray< Size, Value > & | v | ) |
Copy constructor.
Constructs a copy of another static array v.
__cuda_callable__ TNL::Containers::StaticArray< Size, Value >::StaticArray | ( | const std::initializer_list< Value > & | elems | ) |
Constructor which initializes the array by copying elements from std::initializer_list, e.g. {...}
.
The initializer list size must larger or equal to Size.
elems | input initializer list |
__cuda_callable__ TNL::Containers::StaticArray< Size, Value >::StaticArray | ( | const Value & | v1, |
const Value & | v2 | ||
) |
Constructor that sets components of arrays with Size = 2.
v1 | Value of the first array component. |
v2 | Value of the second array component. |
__cuda_callable__ TNL::Containers::StaticArray< Size, Value >::StaticArray | ( | const Value & | v1, |
const Value & | v2, | ||
const Value & | v3 | ||
) |
Constructor that sets components of arrays with Size = 3.
v1 | Value of the first array component. |
v2 | Value of the second array component. |
v3 | Value of the third array component. |
bool TNL::Containers::StaticArray< Size, Value >::load | ( | File & | file | ) |
Loads data from the file to this static array.
file | Reference to a file. |
__cuda_callable__ TNL::Containers::StaticArray< Size, Value >::operator StaticArray< Size, OtherValue > |
Cast operator for changing of the Value type.
Returns static array having ValueType set to OtherValue, i.e. StaticArray< Size, OtherValue >.
OtherValue | is the Value type of the static array the casting will be performed to. |
__cuda_callable__ bool TNL::Containers::StaticArray< Size, Value >::operator!= | ( | const Array & | array | ) | const |
This function checks whether this static array is not equal to another array.
Return true if the arrays are not equal in size. Otherwise returns false.
__cuda_callable__ Value & TNL::Containers::StaticArray< Size, Value >::operator() | ( | int | i | ) |
Accesses specified element at the position i and returns a reference to its value.
Equivalent to operator[].
__cuda_callable__ const Value & TNL::Containers::StaticArray< Size, Value >::operator() | ( | int | i | ) | const |
Accesses specified element at the position i and returns a constant reference to its value.
Equivalent to operator[].
__cuda_callable__ StaticArray< Size, Value > & TNL::Containers::StaticArray< Size, Value >::operator= | ( | const T & | v | ) |
Assigns an object v of type T.
T can be:
__cuda_callable__ bool TNL::Containers::StaticArray< Size, Value >::operator== | ( | const Array & | array | ) | const |
This function checks whether this static array is equal to another array.
Return true if the arrays are equal in size. Otherwise returns false.
__cuda_callable__ Value & TNL::Containers::StaticArray< Size, Value >::operator[] | ( | int | i | ) |
Accesses specified element at the position i and returns a reference to its value.
i | Index position of an element. |
__cuda_callable__ const Value & TNL::Containers::StaticArray< Size, Value >::operator[] | ( | int | i | ) | const |
Accesses specified element at the position i and returns a constant reference to its value.
i | Index position of an element. |
bool TNL::Containers::StaticArray< Size, Value >::save | ( | File & | file | ) | const |
Saves this static array into the file.
file | Reference to a file. |
std::ostream & TNL::Containers::StaticArray< Size, Value >::write | ( | std::ostream & | str, |
const char * | separator = " " |
||
) | const |
Writes the array values into stream str with specified separator.
str | Reference to a stream. |
separator | Character separating the array values in the stream str. Is set to " " by default. |