BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
b8array< T, Capacity > Class Template Reference

A fixed-size array with custom behavior for element initialization. More...

#include <array.h>

Public Member Functions

 b8array (ArrayOptions::InitializationOption option=ArrayOptions::NoFill)
 Construct a new b8array.
 
 b8array (std::initializer_list< T > il)
 Construct a new b8array with an initializer list.
 
 b8array (const b8array &obj)
 Copy constructor for b8array.
 
b8arrayoperator= (const b8array &obj)
 Copy assignment operator.
 
 ~b8array ()
 Destructor to release allocated memory.
 
bool empty () const
 Check if the array is empty.
 
T * begin ()
 Get an iterator pointing to the first element.
 
const T * cbegin () const
 Get a const iterator pointing to the first element.
 
const T * cend () const
 Get a const iterator pointing to one past the last element.
 
T * end ()
 Get an iterator pointing to one past the last element.
 
const T * begin () const
 Get a const iterator pointing to the first element.
 
const T * end () const
 Get a const iterator pointing to one past the last element.
 
T * erase (T *it_)
 Erase an element from the array.
 
void clear ()
 Clear the contents of the array.
 
size_t size () const
 Get the number of elements in the array.
 
void push_back (const T &x_)
 Add an element to the end of the array.
 
T & at (int n_)
 Access element at a specific position.
 
const T & at (int n_) const
 Access element at a specific position (const version).
 
T & operator[] (int n_)
 Overload array subscript operator for non-const objects.
 
const T & operator[] (int n_) const
 Overload array subscript operator for const objects.
 

Detailed Description

template<typename T, size_t Capacity>
class b8array< T, Capacity >

A fixed-size array with custom behavior for element initialization.

Template Parameters
TType of the elements.
CapacityMaximum number of elements the array can hold.

Constructor & Destructor Documentation

◆ b8array() [1/3]

template<typename T , size_t Capacity>
b8array< T, Capacity >::b8array ( ArrayOptions::InitializationOption option = ArrayOptions::NoFill)
inline

Construct a new b8array.

Parameters
optionSpecifies whether the array should be filled with default-constructed elements.

◆ b8array() [2/3]

template<typename T , size_t Capacity>
b8array< T, Capacity >::b8array ( std::initializer_list< T > il)
inline

Construct a new b8array with an initializer list.

Parameters
ilInitializer list with elements to be added to the array.

◆ b8array() [3/3]

template<typename T , size_t Capacity>
b8array< T, Capacity >::b8array ( const b8array< T, Capacity > & obj)
inline

Copy constructor for b8array.

Parameters
objThe b8array to copy from.

Member Function Documentation

◆ at() [1/2]

template<typename T , size_t Capacity>
T & b8array< T, Capacity >::at ( int n_)
inline

Access element at a specific position.

Parameters
n_Index of the element to be accessed.
Returns
Reference to the element at index n_.

◆ at() [2/2]

template<typename T , size_t Capacity>
const T & b8array< T, Capacity >::at ( int n_) const
inline

Access element at a specific position (const version).

Parameters
n_Index of the element to be accessed.
Returns
Const reference to the element at index n_.

◆ begin() [1/2]

template<typename T , size_t Capacity>
T * b8array< T, Capacity >::begin ( )
inline

Get an iterator pointing to the first element.

Returns
Pointer to the first element.

◆ begin() [2/2]

template<typename T , size_t Capacity>
const T * b8array< T, Capacity >::begin ( ) const
inline

Get a const iterator pointing to the first element.

Returns
Const pointer to the first element.

◆ cbegin()

template<typename T , size_t Capacity>
const T * b8array< T, Capacity >::cbegin ( ) const
inline

Get a const iterator pointing to the first element.

Returns
Const pointer to the first element.

◆ cend()

template<typename T , size_t Capacity>
const T * b8array< T, Capacity >::cend ( ) const
inline

Get a const iterator pointing to one past the last element.

Returns
Const pointer to one past the last element.

◆ empty()

template<typename T , size_t Capacity>
bool b8array< T, Capacity >::empty ( ) const
inline

Check if the array is empty.

Returns
true if the array is empty, false otherwise.

◆ end() [1/2]

template<typename T , size_t Capacity>
T * b8array< T, Capacity >::end ( )
inline

Get an iterator pointing to one past the last element.

Returns
Pointer to one past the last element.

◆ end() [2/2]

template<typename T , size_t Capacity>
const T * b8array< T, Capacity >::end ( ) const
inline

Get a const iterator pointing to one past the last element.

Returns
Const pointer to one past the last element.

◆ erase()

template<typename T , size_t Capacity>
T * b8array< T, Capacity >::erase ( T * it_)
inline

Erase an element from the array.

Parameters
it_Iterator pointing to the element to erase.
Returns
Iterator following the removed element.

◆ operator=()

template<typename T , size_t Capacity>
b8array & b8array< T, Capacity >::operator= ( const b8array< T, Capacity > & obj)
inline

Copy assignment operator.

Parameters
objThe b8array to assign from.
Returns
*this

◆ operator[]() [1/2]

template<typename T , size_t Capacity>
T & b8array< T, Capacity >::operator[] ( int n_)
inline

Overload array subscript operator for non-const objects.

Parameters
n_Index of the element to be accessed.
Returns
Reference to the element at index n_.

◆ operator[]() [2/2]

template<typename T , size_t Capacity>
const T & b8array< T, Capacity >::operator[] ( int n_) const
inline

Overload array subscript operator for const objects.

Parameters
n_Index of the element to be accessed.
Returns
Const reference to the element at index n_.

◆ push_back()

template<typename T , size_t Capacity>
void b8array< T, Capacity >::push_back ( const T & x_)
inline

Add an element to the end of the array.

Parameters
x_Element to be added.

◆ size()

template<typename T , size_t Capacity>
size_t b8array< T, Capacity >::size ( ) const
inline

Get the number of elements in the array.

Returns
Number of elements in the array.

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