Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Related Symbols | List of all members
Array< T, N > Struct Template Reference

#include <AH/Containers/Array.hpp>

Detailed Description

template<class T, size_t N>
struct AH::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 32 of file Array.hpp.

+ Collaboration diagram for Array< T, N >:

Public Types

using type = T
 

Public Member Functions

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

Public Attributes

T data [N]
 

Static Public Attributes

static constexpr size_t length = N
 

Related Symbols

(Note that these are not member symbols.)

template<class T1 , class T2 , size_t N1, size_t N2>
Array< decltype(T1 {}+T2 {}), N1operator+ (const Array< T1, N1 > &a, const Array< T2, N2 > &b)
 Array + Array.
 
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.
 
template<class T1 , class T2 , size_t N1, size_t N2>
Array< decltype(T1 {} - T2 {}), N1operator- (const Array< T1, N1 > &a, const Array< T2, N2 > &b)
 Array - Array.
 
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.
 
template<class T1 , class T2 , size_t N1>
Array< decltype(T1 {} *T2 {}), N1operator* (const Array< T1, N1 > &a, T2 b)
 Array * Scalar.
 
template<class T1 , class T2 , size_t N2>
Array< decltype(T1 {} *T2 {}), N2operator* (T1 a, const Array< T2, N2 > &b)
 Scalar * Array.
 
template<class T1 , class T2 , size_t N1>
Array< T1, N1 > & operator*= (Array< T1, N1 > &a, T2 b)
 Array *= Scalar.
 
template<class T1 , class T2 , size_t N1>
Array< decltype(T1 {}/T2 {}), N1operator/ (const Array< T1, N1 > &a, T2 b)
 Array / Scalar.
 
template<class T1 , class T2 , size_t N1>
Array< T1, N1 > & operator/= (Array< T1, N1 > &a, T2 b)
 Array /= Scalar.
 
template<class T , size_t N>
Array< decltype(-T {}), N > operator- (const Array< T, N > &a)
 -Array
 

Member Typedef Documentation

◆ type

template<class T , size_t N>
using type = T

Definition at line 34 of file Array.hpp.

Member Function Documentation

◆ operator[]() [1/2]

template<class T , size_t N>
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 46 of file Array.hpp.

◆ operator[]() [2/2]

template<class T , size_t N>
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 63 of file Array.hpp.

◆ begin() [1/2]

template<class T , size_t N>
T * begin ( )
inline

Get a pointer to the first element.

Definition at line 74 of file Array.hpp.

◆ begin() [2/2]

template<class T , size_t N>
const T * begin ( ) const
inline

Get a pointer to the first element.

Definition at line 79 of file Array.hpp.

◆ end() [1/2]

template<class T , size_t N>
T * end ( )
inline

Get a pointer to the memory beyond the array.

Definition at line 84 of file Array.hpp.

◆ end() [2/2]

template<class T , size_t N>
const T * end ( ) const
inline

Get a pointer to the memory beyond the array.

Definition at line 89 of file Array.hpp.

◆ operator==()

template<class T , size_t N>
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 97 of file Array.hpp.

◆ operator!=()

template<class T , size_t N>
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 112 of file Array.hpp.

◆ slice() [1/2]

template<class T , size_t N>
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.

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.

◆ slice() [2/2]

template<class T , size_t N>
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.

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.

◆ cslice()

template<class T , size_t N>
template<size_t Start = 0, size_t End = N - 1>
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 142 of file Array.hpp.

Member Data Documentation

◆ data

template<class T , size_t N>
T data[N]

Definition at line 33 of file Array.hpp.

◆ length

template<class T , size_t N>
constexpr size_t length = N
staticconstexpr

Definition at line 35 of file Array.hpp.


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