ScapeGoatTree
Loading...
Searching...
No Matches
Vector< T > Class Template Reference

#include <vector.hpp>

Public Member Functions

 ~Vector ()
 
 Vector ()=default
 
unsigned int size () const
 
void push_back (const T &value)
 
T pop_back ()
 
Tbegin ()
 
Tend ()
 
Toperator[] (unsigned int index)
 
const Toperator[] (unsigned int index) const
 
 Vector (const Vector &other)
 
Vectoroperator= (const Vector &other)
 
 Vector (Vector &&other) noexcept
 
Vectoroperator= (Vector &&other) noexcept
 

Private Attributes

unsigned int _size = 50
 
int nElements = 0
 
Tdata = new T[_size]{}
 

Friends

template<typename >
class Stack
 
template<typename >
class ScapeGoatTree
 

Constructor & Destructor Documentation

◆ ~Vector()

template<typename T >
Vector< T >::~Vector ( )
inline

Destroys the vector and releases the dynamically allocated memory.

◆ Vector() [1/3]

template<typename T >
Vector< T >::Vector ( )
default

Default constructor for the Vector class.

◆ Vector() [2/3]

template<typename T >
Vector< T >::Vector ( const Vector< T > &  other)
inline

◆ Vector() [3/3]

template<typename T >
Vector< T >::Vector ( Vector< T > &&  other)
inlinenoexcept

Member Function Documentation

◆ begin()

template<typename T >
T * Vector< T >::begin ( )
inline

◆ end()

template<typename T >
T * Vector< T >::end ( )
inline

◆ operator=() [1/2]

template<typename T >
Vector & Vector< T >::operator= ( const Vector< T > &  other)
inline

◆ operator=() [2/2]

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

◆ operator[]() [1/2]

template<typename T >
T & Vector< T >::operator[] ( unsigned int  index)
inline

Provides access to the element at the specified index.

◆ operator[]() [2/2]

template<typename T >
const T & Vector< T >::operator[] ( unsigned int  index) const
inline

Provides read-only access to the element at the specified index.

◆ pop_back()

template<typename T >
T Vector< T >::pop_back ( )
inline

Removes and returns the last element. Throws std::out_of_range if the vector is empty. Shrinks internal storage when usage falls to 1/4 of capacity (min capacity 50).

◆ push_back()

template<typename T >
void Vector< T >::push_back ( const T value)
inline

Appends a new element to the end of the vector, resizing if necessary.

◆ size()

template<typename T >
unsigned int Vector< T >::size ( ) const
inline

Returns the number of elements currently stored in the vector.

Friends And Related Symbol Documentation

◆ ScapeGoatTree

template<typename T >
template<typename >
friend class ScapeGoatTree
friend

◆ Stack

template<typename T >
template<typename >
friend class Stack
friend

Member Data Documentation

◆ _size

template<typename T >
unsigned int Vector< T >::_size = 50
private

◆ data

template<typename T >
T* Vector< T >::data = new T[_size]{}
private

◆ nElements

template<typename T >
int Vector< T >::nElements = 0
private

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