Arduino Filters master
Filter library for Arduino
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Related Functions | List of all members
Array< T, N > Struct Template Reference

#include <AH/Containers/Array.hpp>

Detailed Description

template<class T, size_t N>
struct Array< T, N >

An array wrapper for easy copying, comparing, and iterating.

Template Parameters
TThe type of the elements in the array.
NThe number of elements in the array.

Definition at line 36 of file Array.hpp.

+ Collaboration diagram for Array< T, N >:

Public Types

using type = T
 

Public Member Functions

T & operator[] (size_t index)
 Get the element at the given index. More...
 
const T & operator[] (size_t index) const
 Get the element at the given index. More...
 
T * begin ()
 Get a pointer to the first element. More...
 
const T * begin () const
 Get a pointer to the first element. More...
 
T * end ()
 Get a pointer to the memory beyond the array. More...
 
const T * end () const
 Get a pointer to the memory beyond the array. More...
 
bool operator== (const Array< T, N > &rhs) const
 Check the equality of all elements in two arrays. More...
 
bool operator!= (const Array< T, N > &rhs) const
 Check the inequality of all elements in two arrays. More...
 
template<size_t Start = 0, size_t End = N - 1>
ArraySlice< T, abs_diff(Start, End)+1,(End< Start), false > slice ()
 Get a view on a slice of the Array. More...
 
template<size_t Start = 0, size_t End = N - 1>
ArraySlice< T, abs_diff(Start, End)+1,(End< Start), true > slice () const
 Get a read-only view on a slice of the Array. More...
 
template<size_t Start = 0, size_t End = N - 1>
ArraySlice< T, abs_diff(Start, End)+1,(End< Start), true > cslice () const
 Get a read-only view on a slice of the Array. More...
 

Public Attributes

data [N]
 

Static Public Attributes

static constexpr size_t length = N
 

Related Functions

(Note that these are not member functions.)

template<class T1 , class T2 , size_t N1, size_t N2>
Array< decltype(T1{}+T2{}), N1 > operator+ (const Array< T1, N1 > &a, const Array< T2, N2 > &b)
 Array + Array. More...
 
template<class T1 , class T2 , size_t N1, size_t N2>
Array< T1, N1 > & operator+= (Array< T1, N1 > &a, const Array< T2, N2 > &b)
 Array += Array. More...
 
template<class T1 , class T2 , size_t N1, size_t N2>
Array< decltype(T1{} - T2{}), N1 > operator- (const Array< T1, N1 > &a, const Array< T2, N2 > &b)
 Array - Array. More...
 
template<class T1 , class T2 , size_t N1, size_t N2>
Array< T1, N1 > & operator-= (Array< T1, N1 > &a, const Array< T2, N2 > &b)
 Array -= Array. More...
 
template<class T1 , class T2 , size_t N1>
Array< decltype(T1{} *T2{}), N1 > operator* (const Array< T1, N1 > &a, T2 b)
 Array * Scalar. More...
 
template<class T1 , class T2 , size_t N2>
Array< decltype(T1{} *T2{}), N2 > operator* (T1 a, const Array< T2, N2 > &b)
 Scalar * Array. More...
 
template<class T1 , class T2 , size_t N1>
Array< T1, N1 > & operator*= (Array< T1, N1 > &a, T2 b)
 Array *= Scalar. More...
 
template<class T1 , class T2 , size_t N1>
Array< decltype(T1{}/T2{}), N1 > operator/ (const Array< T1, N1 > &a, T2 b)
 Array / Scalar. More...
 
template<class T1 , class T2 , size_t N1>
Array< T1, N1 > & operator/= (Array< T1, N1 > &a, T2 b)
 Array /= Scalar. More...
 
template<class T , size_t N>
Array< decltype(-T{}), N > operator- (const Array< T, N > &a)
 -Array More...
 

Member Typedef Documentation

◆ type

using type = T

Definition at line 38 of file Array.hpp.

Member Function Documentation

◆ operator[]() [1/2]

T & operator[] ( size_t  index)
inline

Get the element at the given index.

Note
Bounds checking is performed. If fatal errors are disabled, the last element is returned if the index is out of bounds.
Parameters
indexThe (zero-based) index of the element to return.

Definition at line 50 of file Array.hpp.

◆ operator[]() [2/2]

const T & operator[] ( size_t  index) const
inline

Get the element at the given index.

Note
Bounds checking is performed. If fatal errors are disabled, the last element is returned if the index is out of bounds.
Parameters
indexThe (zero-based) index of the element to return.

Definition at line 67 of file Array.hpp.

◆ begin() [1/2]

T * begin ( )
inline

Get a pointer to the first element.

Definition at line 78 of file Array.hpp.

◆ begin() [2/2]

const T * begin ( ) const
inline

Get a pointer to the first element.

Definition at line 83 of file Array.hpp.

◆ end() [1/2]

T * end ( )
inline

Get a pointer to the memory beyond the array.

Definition at line 88 of file Array.hpp.

◆ end() [2/2]

const T * end ( ) const
inline

Get a pointer to the memory beyond the array.

Definition at line 93 of file Array.hpp.

◆ operator==()

bool operator== ( const Array< T, N > &  rhs) const
inline

Check the equality of all elements in two arrays.

Parameters
rhsThe array to compare this array to.

Definition at line 101 of file Array.hpp.

◆ operator!=()

bool operator!= ( const Array< T, N > &  rhs) const
inline

Check the inequality of all elements in two arrays.

Parameters
rhsThe array to compare this array to.

Definition at line 116 of file Array.hpp.

◆ cslice()

ArraySlice< T, abs_diff(Start, End)+1,(End< Start), true > cslice ( ) const
inline

Get a read-only view on a slice of the Array.

Doesn't copy the contents of the array, it's just a reference to the original array.

Template Parameters
StartThe start index of the slice.
EndThe end index of the slice.

Definition at line 146 of file Array.hpp.

Member Data Documentation

◆ data

T data[N]

Definition at line 37 of file Array.hpp.

◆ length

constexpr size_t length = N
staticconstexpr

Definition at line 39 of file Array.hpp.


The documentation for this struct was generated from the following file: