Control Surface  1.2.0
MIDI Control Surface library for Arduino
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Array< T, N > Struct Template Reference

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

#include <AH/Containers/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

constexpr static size_t length = N
 

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 36 of file Array.hpp.

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.

◆ slice() [1/2]

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]

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()

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 static size_t length = N
staticconstexpr

Definition at line 39 of file Array.hpp.


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