Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
Containers

Detailed Description

Containers like Array, BitArray, DoublyLinkedList.

+ Collaboration diagram for Containers:

Classes

class  ArraySlice< T, N, Reverse, Const >
 Class for a view on a slice of an array. More...
 
struct  Array< T, N >
 An array wrapper for easy copying, comparing, and iterating. More...
 
class  BitArray< N >
 A class for arrays of bits. More...
 
class  DoublyLinkedList< Node >
 A class for doubly linked lists. More...
 
class  DoublyLinkable< Node >
 A class that can be inherited from to allow inserting into a DoublyLinkedList. More...
 

Typedefs

template<class T , size_t NumRows, size_t NumCols>
using Array2D = Array<Array<T, NumCols>, NumRows>
 An easy alias for two-dimensional Arrays.
 

Functions

template<class T , size_t N, class G >
Array< T, N > generateArray (G generator)
 Generate an array using the given generator.
 
template<size_t N, class G >
auto generateArray (G generator) -> Array< decltype(generator()), N >
 Generate an array using the given generator.
 
template<class T , size_t N, class U >
Array< T, N > copyAs (const Array< U, N > &src)
 Copy an Array to an Array of a different type.
 
template<class F , class U , size_t N>
Array< decltype(F{}(U{})), N > apply (const Array< U, N > &src, F f)
 Apply a function to all elements of the array and return a copy.
 
template<class T , size_t N, class... Args>
Array< T, N > fillArray (Args... args)
 Fill the array with the same value for each element.
 
template<class T , size_t N, class U , class V = U>
Array< T, N > generateIncrementalArray (U start=0, V increment=V(1))
 Generate an array where the first value is given, and the subsequent values are calculated as the previous value incremented with a given value:
\( x[0] = \mathrm{start} \)
\( x[k+1] = x[k] + \mathrm{increment} \) .
 
template<class T , size_t M, size_t N>
Array< T, M+N > cat (const Array< T, M > &a, const Array< T, N > &b)
 Concatenate two arrays.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const Array< T2, N2 > &b)
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const Array< T1, N1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 
template<class T1 , class T2 , size_t N1, size_t N2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const Array< T1, N1 > &a, const Array< T2, N2 > &b)
 
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 >
 
template<size_t Start, size_t End>
auto slice () const -> ArraySlice< T, abs_diff(End, Start)+1, Reverse ^(End< Start), Const >
 
template<class T , size_t N, bool Reverse, bool Const>
ArraySlice< T, N, Reverse, Const >::iterator operator+ (typename ArraySlice< T, N, Reverse, Const >::iterator::difference_type n, typename ArraySlice< T, N, Reverse, Const >::iterator a)
 <T, N, Reverse, Const>iterator
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
bool operator== (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice == Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
bool operator== (const Array< T1, N1 > &a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Array == Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
bool operator== (ArraySlice< T1, N1, Reverse1, Const1 > a, const Array< T2, N2 > &b)
 Slice == Array.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
bool operator!= (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice != Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
bool operator!= (const Array< T1, N1 > &a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Array != Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
bool operator!= (ArraySlice< T1, N1, Reverse1, Const1 > a, const Array< T2, N2 > &b)
 Slice != Array.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1 {}+T2 {}), N1operator+ (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice + Slice.
 
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, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator+= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 Slice += Slice.
 
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, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1 {} - T2 {}), N1operator- (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice - Slice.
 
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, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator-= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 Slice -= Slice.
 
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, bool Reverse1, bool Const1>
Array< decltype(T1 {} *T2 {}), N1operator* (ArraySlice< T1, N1, Reverse1, Const1 > a, T2 b)
 Slice * 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 N2, bool Reverse2, bool Const2>
Array< decltype(T1 {} *T2 {}), N2operator* (T1 a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Scalar * Slice.
 
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, bool Reverse1, bool Const1>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator*= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, T2 b)
 Slice *= Scalar.
 
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, bool Reverse1, bool Const1>
Array< decltype(T1 {}/T2 {}), N1operator/ (ArraySlice< T1, N1, Reverse1, Const1 > a, T2 b)
 Slice / 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, bool Reverse1, bool Const1>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator/= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, T2 b)
 Slice /= 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, bool Reverse, bool Const>
Array< decltype(-T {}), N > operator- (ArraySlice< T, N, Reverse, Const > a)
 -Slice
 
template<class T , size_t N>
Array< decltype(-T {}), N > operator- (const Array< T, N > &a)
 -Array
 

Typedef Documentation

◆ Array2D

template<class T , size_t NumRows, size_t NumCols>
using Array2D = Array<Array<T, NumCols>, NumRows>

An easy alias for two-dimensional Arrays.

Definition at line 529 of file Array.hpp.

Function Documentation

◆ generateArray() [1/2]

template<class T , size_t N, class G >
Array< T, N > generateArray ( G generator)

Generate an array using the given generator.

Template Parameters
TThe type of the elements in the array.
NThe number of elements in the array.
GThe generator functor type.
Parameters
generatorA functor that will be called to create each element.
Returns
The generated array.

Definition at line 64 of file ArrayHelpers.hpp.

◆ generateArray() [2/2]

template<size_t N, class G >
auto generateArray ( G generator) -> Array<decltype(generator()), N>

Generate an array using the given generator.

Template Parameters
NThe number of elements in the array.
GThe generator functor type.
Parameters
generatorA functor that will be called to create each element.
Returns
The generated array.

Definition at line 84 of file ArrayHelpers.hpp.

◆ copyAs()

template<class T , size_t N, class U >
Array< T, N > copyAs ( const Array< U, N > & src)

Copy an Array to an Array of a different type.

Template Parameters
TThe type of the new array.
NThe number of elements in the arrays.
UThe type of the source array.
Parameters
srcThe source array to be copied.

Definition at line 105 of file ArrayHelpers.hpp.

◆ apply()

template<class F , class U , size_t N>
Array< decltype(F{}(U{})), N > apply ( const Array< U, N > & src,
F f )

Apply a function to all elements of the array and return a copy.

Definition at line 117 of file ArrayHelpers.hpp.

◆ fillArray()

template<class T , size_t N, class... Args>
Array< T, N > fillArray ( Args... args)

Fill the array with the same value for each element.

Definition at line 129 of file ArrayHelpers.hpp.

◆ generateIncrementalArray()

template<class T , size_t N, class U , class V = U>
Array< T, N > generateIncrementalArray ( U start = 0,
V increment = V(1) )

Generate an array where the first value is given, and the subsequent values are calculated as the previous value incremented with a given value:
\( x[0] = \mathrm{start} \)
\( x[k+1] = x[k] + \mathrm{increment} \) .

For example:

A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...

is equivalent to

Array<unsigned int, 4> x = {2, 5, 8, 11};
Template Parameters
TThe type of the elements in the array.
NThe number of elements in the array.
UThe type of the initial value.
VThe type of the value that will be added to each subsequent element.
Parameters
startThe first value in the array.
incrementThe value to add to each subsequent element of the array.
Returns
The generated array.

Definition at line 176 of file ArrayHelpers.hpp.

◆ cat()

template<class T , size_t M, size_t N>
Array< T, M+N > cat ( const Array< T, M > & a,
const Array< T, N > & b )

Concatenate two arrays.

Template Parameters
TThe type of the elements in the array.
MThe number of elements in the first array.
NThe number of elements in the second array.
Parameters
aThe first array.
bThe second array.
Returns
A new array containing the elements of both input arrays (in order).

Definition at line 197 of file ArrayHelpers.hpp.

◆ distribute() [1/4]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute ( const ArraySlice< T1, N1, Reverse1, Const1 > & a,
const ArraySlice< T2, N2, Reverse2, Const2 > & b )

Definition at line 211 of file ArrayHelpers.hpp.

◆ distribute() [2/4]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute ( const ArraySlice< T1, N1, Reverse1, Const1 > & a,
const Array< T2, N2 > & b )

Definition at line 222 of file ArrayHelpers.hpp.

◆ distribute() [3/4]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute ( const Array< T1, N1 > & a,
const ArraySlice< T2, N2, Reverse2, Const2 > & b )

Definition at line 229 of file ArrayHelpers.hpp.

◆ distribute() [4/4]

template<class T1 , class T2 , size_t N1, size_t N2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute ( const Array< T1, N1 > & a,
const Array< T2, N2 > & b )

Definition at line 236 of file ArrayHelpers.hpp.

◆ slice() [1/3]

template<class T , size_t N>
template<size_t Start, size_t End>
auto slice ( ) -> ArraySlice<T, abs_diff(Start, End) + 1, (End < Start), false>

Definition at line 231 of file Array.hpp.

◆ slice() [2/3]

template<class T , size_t N>
template<size_t Start, size_t End>
auto slice ( ) const -> ArraySlice<T, abs_diff(Start, End) + 1, (End < Start), true>

Definition at line 240 of file Array.hpp.

◆ slice() [3/3]

template<class T , size_t N, bool Reverse = false, bool Const = true>
template<size_t Start, size_t End>
auto slice ( ) const -> ArraySlice<T, abs_diff(End, Start) + 1, Reverse ^ (End < Start), Const>

Definition at line 249 of file Array.hpp.

◆ operator+() [1/3]

template<class T , size_t N, bool Reverse, bool Const>
ArraySlice< T, N, Reverse, Const >::iterator operator+ ( typename ArraySlice< T, N, Reverse, Const >::iterator::difference_type n,
typename ArraySlice< T, N, Reverse, Const >::iterator a )
related

<T, N, Reverse, Const>iterator

Definition at line 258 of file Array.hpp.

◆ operator==() [1/3]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
bool operator== ( ArraySlice< T1, N1, Reverse1, Const1 > a,
ArraySlice< T2, N2, Reverse2, Const2 > b )
related

Slice == Slice.

Definition at line 270 of file Array.hpp.

◆ operator==() [2/3]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
bool operator== ( const Array< T1, N1 > & a,
ArraySlice< T2, N2, Reverse2, Const2 > b )
related

Array == Slice.

Definition at line 282 of file Array.hpp.

◆ operator==() [3/3]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
bool operator== ( ArraySlice< T1, N1, Reverse1, Const1 > a,
const Array< T2, N2 > & b )
related

Slice == Array.

Definition at line 290 of file Array.hpp.

◆ operator!=() [1/3]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
bool operator!= ( ArraySlice< T1, N1, Reverse1, Const1 > a,
ArraySlice< T2, N2, Reverse2, Const2 > b )
related

Slice != Slice.

Definition at line 301 of file Array.hpp.

◆ operator!=() [2/3]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
bool operator!= ( const Array< T1, N1 > & a,
ArraySlice< T2, N2, Reverse2, Const2 > b )
related

Array != Slice.

Definition at line 309 of file Array.hpp.

◆ operator!=() [3/3]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
bool operator!= ( ArraySlice< T1, N1, Reverse1, Const1 > a,
const Array< T2, N2 > & b )
related

Slice != Array.

Definition at line 317 of file Array.hpp.

◆ operator+() [2/3]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1 {}+T2 {}), N1 > operator+ ( ArraySlice< T1, N1, Reverse1, Const1 > a,
ArraySlice< T2, N2, Reverse2, Const2 > b )
related

Slice + Slice.

Definition at line 329 of file Array.hpp.

◆ operator+() [3/3]

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

Array + Array.

Definition at line 341 of file Array.hpp.

◆ operator+=() [1/2]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator+= ( const ArraySlice< T1, N1, Reverse1, Const1 > & a,
const ArraySlice< T2, N2, Reverse2, Const2 > & b )
related

Slice += Slice.

Definition at line 351 of file Array.hpp.

◆ operator+=() [2/2]

template<class T1 , class T2 , size_t N1, size_t N2>
Array< T1, N1 > & operator+= ( Array< T1, N1 > & a,
const Array< T2, N2 > & b )
related

Array += Array.

Definition at line 362 of file Array.hpp.

◆ operator-() [1/4]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1 {} - T2 {}), N1 > operator- ( ArraySlice< T1, N1, Reverse1, Const1 > a,
ArraySlice< T2, N2, Reverse2, Const2 > b )
related

Slice - Slice.

Definition at line 374 of file Array.hpp.

◆ operator-() [2/4]

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

Array - Array.

Definition at line 386 of file Array.hpp.

◆ operator-=() [1/2]

template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator-= ( const ArraySlice< T1, N1, Reverse1, Const1 > & a,
const ArraySlice< T2, N2, Reverse2, Const2 > & b )
related

Slice -= Slice.

Definition at line 396 of file Array.hpp.

◆ operator-=() [2/2]

template<class T1 , class T2 , size_t N1, size_t N2>
Array< T1, N1 > & operator-= ( Array< T1, N1 > & a,
const Array< T2, N2 > & b )
related

Array -= Array.

Definition at line 407 of file Array.hpp.

◆ operator*() [1/4]

template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
Array< decltype(T1 {} *T2 {}), N1 > operator* ( ArraySlice< T1, N1, Reverse1, Const1 > a,
T2 b )
related

Slice * Scalar.

Definition at line 418 of file Array.hpp.

◆ operator*() [2/4]

template<class T1 , class T2 , size_t N1>
Array< decltype(T1 {} *T2 {}), N1 > operator* ( const Array< T1, N1 > & a,
T2 b )
related

Array * Scalar.

Definition at line 428 of file Array.hpp.

◆ operator*() [3/4]

template<class T1 , class T2 , size_t N2, bool Reverse2, bool Const2>
Array< decltype(T1 {} *T2 {}), N2 > operator* ( T1 a,
ArraySlice< T2, N2, Reverse2, Const2 > b )
related

Scalar * Slice.

Definition at line 436 of file Array.hpp.

◆ operator*() [4/4]

template<class T1 , class T2 , size_t N2>
Array< decltype(T1 {} *T2 {}), N2 > operator* ( T1 a,
const Array< T2, N2 > & b )
related

Scalar * Array.

Definition at line 446 of file Array.hpp.

◆ operator*=() [1/2]

template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator*= ( const ArraySlice< T1, N1, Reverse1, Const1 > & a,
T2 b )
related

Slice *= Scalar.

Definition at line 454 of file Array.hpp.

◆ operator*=() [2/2]

template<class T1 , class T2 , size_t N1>
Array< T1, N1 > & operator*= ( Array< T1, N1 > & a,
T2 b )
related

Array *= Scalar.

Definition at line 463 of file Array.hpp.

◆ operator/() [1/2]

template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
Array< decltype(T1 {}/T2 {}), N1 > operator/ ( ArraySlice< T1, N1, Reverse1, Const1 > a,
T2 b )
related

Slice / Scalar.

Definition at line 474 of file Array.hpp.

◆ operator/() [2/2]

template<class T1 , class T2 , size_t N1>
Array< decltype(T1 {}/T2 {}), N1 > operator/ ( const Array< T1, N1 > & a,
T2 b )
related

Array / Scalar.

Definition at line 484 of file Array.hpp.

◆ operator/=() [1/2]

template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator/= ( const ArraySlice< T1, N1, Reverse1, Const1 > & a,
T2 b )
related

Slice /= Scalar.

Definition at line 492 of file Array.hpp.

◆ operator/=() [2/2]

template<class T1 , class T2 , size_t N1>
Array< T1, N1 > & operator/= ( Array< T1, N1 > & a,
T2 b )
related

Array /= Scalar.

Definition at line 501 of file Array.hpp.

◆ operator-() [3/4]

template<class T , size_t N, bool Reverse, bool Const>
Array< decltype(-T {}), N > operator- ( ArraySlice< T, N, Reverse, Const > a)
related

-Slice

Definition at line 511 of file Array.hpp.

◆ operator-() [4/4]

template<class T , size_t N>
Array< decltype(-T {}), N > operator- ( const Array< T, N > & a)
related

-Array

Definition at line 521 of file Array.hpp.