Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::Array< T > Class Template Reference

#include <Array.h>

Public Member Functions

 Array ()
 Constructs an empty Array.
 
 Array (size_t capacity)
 Constructs an Array with the given capacity, allocating memory.
 
 Array (size_t size, const T *values)
 Constructs an Array from an existing C-style array.
 
 Array (const Array &other)=delete
 Copy constructor (deleted to prevent accidental copying).
 
 Array (Array &&other) noexcept
 Move constructor.
 
Arrayoperator= (const Array &other)=delete
 Copy assignment operator (deleted to prevent accidental copying).
 
Arrayoperator= (Array &&other) noexcept
 Move assignment operator.
 
 ~Array ()
 Destructor that deallocates the array memory.
 
T & operator[] (size_t index)
 Provides access to the array elements without bounds checking.
 
const T & operator[] (size_t index) const
 Provides read-only access to the array elements without bounds checking.
 
bool get (size_t index, T &outValue) const
 Provides access to the array elements with bounds checking.
 
bool set (size_t index, const T &value)
 Sets the value of an element in the array.
 
size_t size () const
 Returns the size of the array.
 
size_t capacity () const
 Returns the capacity of the array.
 
bool isEmpty () const
 Checks if the array is empty.
 
const T * raw () const
 Retrieves a const pointer to the underlying data.
 
bool reserve (size_t newCapacity)
 Reserves memory for at least the specified number of elements.
 
bool push (const T &value)
 Adds a new element to the end of the array using copy semantics.
 
bool push (T &&value)
 Adds a new element to the end of the array using move semantics.
 
void clear ()
 Clears the array, setting its size to zero.
 
bool shrink ()
 Reduces the capacity to fit the current size.
 

Constructor & Destructor Documentation

◆ Array() [1/5]

template<typename T>
uniot::Array< T >::Array ( )
inline

Constructs an empty Array.

◆ Array() [2/5]

template<typename T>
uniot::Array< T >::Array ( size_t capacity)
inline

Constructs an Array with the given capacity, allocating memory.

Parameters
capacityThe number of elements in the array.

◆ Array() [3/5]

template<typename T>
uniot::Array< T >::Array ( size_t size,
const T * values )
inline

Constructs an Array from an existing C-style array.

Parameters
sizeThe number of elements in the array.
valuesPointer to the first element of the array.

◆ Array() [4/5]

template<typename T>
uniot::Array< T >::Array ( const Array< T > & other)
delete

Copy constructor (deleted to prevent accidental copying).

◆ Array() [5/5]

template<typename T>
uniot::Array< T >::Array ( Array< T > && other)
inlinenoexcept

Move constructor.

Parameters
otherThe Array to move from.

◆ ~Array()

template<typename T>
uniot::Array< T >::~Array ( )
inline

Destructor that deallocates the array memory.

Member Function Documentation

◆ capacity()

template<typename T>
size_t uniot::Array< T >::capacity ( ) const
inline

Returns the capacity of the array.

Return values
size_tThe number of elements that can be stored without reallocating.

◆ clear()

template<typename T>
void uniot::Array< T >::clear ( )
inline

Clears the array, setting its size to zero.

◆ get()

template<typename T>
bool uniot::Array< T >::get ( size_t index,
T & outValue ) const
inline

Provides access to the array elements with bounds checking.

Parameters
indexThe index of the element.
outValueReference to store the retrieved value.
Return values
trueThe element was retrieved successfully.
falseThe index is out of bounds.

◆ isEmpty()

template<typename T>
bool uniot::Array< T >::isEmpty ( ) const
inline

Checks if the array is empty.

Return values
trueThe array is empty.
falseThe array contains elements.

◆ operator=() [1/2]

template<typename T>
Array & uniot::Array< T >::operator= ( Array< T > && other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe Array to move from.
Return values
Array&Reference to the current Array.

◆ operator=() [2/2]

template<typename T>
Array & uniot::Array< T >::operator= ( const Array< T > & other)
delete

Copy assignment operator (deleted to prevent accidental copying).

◆ operator[]() [1/2]

template<typename T>
T & uniot::Array< T >::operator[] ( size_t index)
inline

Provides access to the array elements without bounds checking.

Parameters
indexThe index of the element.
Return values
T&Reference to the element at the specified index.

◆ operator[]() [2/2]

template<typename T>
const T & uniot::Array< T >::operator[] ( size_t index) const
inline

Provides read-only access to the array elements without bounds checking.

Parameters
indexThe index of the element.
Return values
T&Const reference to the element at the specified index.

◆ push() [1/2]

template<typename T>
bool uniot::Array< T >::push ( const T & value)
inline

Adds a new element to the end of the array using copy semantics.

Parameters
valueThe value to add.
Return values
trueThe push was successful.
falseThe push failed (e.g., memory allocation error).

◆ push() [2/2]

template<typename T>
bool uniot::Array< T >::push ( T && value)
inline

Adds a new element to the end of the array using move semantics.

Parameters
valueThe value to add.
Return values
trueThe push was successful.
falseThe push failed (e.g., memory allocation error).

◆ raw()

template<typename T>
const T * uniot::Array< T >::raw ( ) const
inline

Retrieves a const pointer to the underlying data.

Return values
T*Const pointer to the first element of the array.

◆ reserve()

template<typename T>
bool uniot::Array< T >::reserve ( size_t newCapacity)
inline

Reserves memory for at least the specified number of elements.

Parameters
newCapacityThe desired capacity.
Return values
trueThe reservation was successful.
falseThe reservation failed (e.g., memory allocation error).

◆ set()

template<typename T>
bool uniot::Array< T >::set ( size_t index,
const T & value )
inline

Sets the value of an element in the array.

Parameters
indexThe index of the element.
valueThe value to set.
Return values
trueThe element was set successfully.
falseThe index is out of bounds.

◆ shrink()

template<typename T>
bool uniot::Array< T >::shrink ( )
inline

Reduces the capacity to fit the current size.

Return values
trueThe shrink was successful.
falseThe shrink failed (e.g., memory allocation error).

◆ size()

template<typename T>
size_t uniot::Array< T >::size ( ) const
inline

Returns the size of the array.

Return values
size_tThe size of the array.

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