Refureku v2.2.0
C++17 runtime reflection library.
rfk::Vector< T, Allocator > Class Template Reference

Public Types

using value_type = T
 
using allocator_type = Allocator
 
using reference = value_type &
 
using const_reference = value_type const &
 

Public Member Functions

 Vector (std::size_t initialCapacity=0u) noexcept
 
template<typename U , typename UAlloc >
 Vector (Vector< U, UAlloc > &&) noexcept
 
 Vector (Vector const &)
 
 Vector (Vector &&) noexcept
 
T & front () noexcept
 Get a reference to the first element of the vector. The behaviour is undefined if the vector is empty. More...
 
T const & front () const noexcept
 
T & back () noexcept
 Get a reference to the last element of the vector. The behaviour is undefined if the vector is empty. More...
 
T const & back () const noexcept
 
T * data () noexcept
 Get a pointer to the underlying allocated memory. More...
 
T const * data () const noexcept
 
void reserve (std::size_t capacity)
 Reallocate the underlying memory to have enough space to fit capacity elements. No reallocation happens if the provided capacity is equal or smaller than the current capacity. More...
 
void resize (std::size_t size)
 Resize the vector so that it has exactly the specified size. Reallocation occurs if the size is greater than the current capacity. Objects are default constructed if the specified size is greater than the current size. More...
 
std::size_t size () const noexcept
 Get the number of elements stored in the vector. More...
 
std::size_t capacity () const noexcept
 Get the maximum number of elements storable in the vector without reallocation. More...
 
bool empty () const noexcept
 Check if the container contains no elements. More...
 
void clear ()
 Remove all elements from the vector.
 
void push_back (T const &value)
 Add an element to the vector. More...
 
void push_back (T &&value)
 Add an element to the vector. More...
 
void push_back (Vector const &other)
 Add all elements from a vector at the end of this vector. More...
 
void push_back (Vector &&other)
 
void insert (std::size_t index, T const &element)
 Insert an element at a specified index. More...
 
void insert (std::size_t index, T &&element)
 Insert an element at a specified index. More...
 
template<typename... Args>
T & emplace_back (Args &&... args)
 Construct in place an element at the end of the vector with the provided arguments. More...
 
T * begin () noexcept
 Get a pointer to the first element. If the vector is empty, the pointed memory is undefined. More...
 
T const * begin () const noexcept
 
T const * cbegin () const noexcept
 
T * end () noexcept
 Get a pointer past the last element. More...
 
T const * end () const noexcept
 
T const * cend () const noexcept
 
T & operator[] (std::size_t index) noexcept
 Access the index(th) element in the vector. More...
 
T const & operator[] (std::size_t index) const noexcept
 
Vectoroperator= (Vector const &)
 
Vectoroperator= (Vector &&) noexcept
 

Constructor & Destructor Documentation

◆ Vector()

template<typename T , typename Allocator = rfk::Allocator<T>>
template<typename U , typename UAlloc >
rfk::Vector< T, Allocator >::Vector ( Vector< U, UAlloc > &&  )
noexcept

Retrieve data from another type U. NOT SAFE UNLESS YOU EXACTLY KNOW WHAT YOU DO.

Member Function Documentation

◆ back()

template<typename T , typename Allocator = rfk::Allocator<T>>
T & rfk::Vector< T, Allocator >::back ( )
noexcept

Get a reference to the last element of the vector. The behaviour is undefined if the vector is empty.

Returns
A reference to the last element of the vector.

◆ begin()

template<typename T , typename Allocator = rfk::Allocator<T>>
T * rfk::Vector< T, Allocator >::begin ( )
noexcept

Get a pointer to the first element. If the vector is empty, the pointed memory is undefined.

Returns
A pointer to the first element.

◆ capacity()

template<typename T , typename Allocator = rfk::Allocator<T>>
std::size_t rfk::Vector< T, Allocator >::capacity ( ) const
noexcept

Get the maximum number of elements storable in the vector without reallocation.

Returns
The maximum number of elements storable in the vector without reallocation.

◆ data()

template<typename T , typename Allocator = rfk::Allocator<T>>
T * rfk::Vector< T, Allocator >::data ( )
noexcept

Get a pointer to the underlying allocated memory.

Returns
A pointer to the underlying allocated memory.

◆ emplace_back()

template<typename T , typename Allocator = rfk::Allocator<T>>
template<typename... Args>
T & rfk::Vector< T, Allocator >::emplace_back ( Args &&...  args)

Construct in place an element at the end of the vector with the provided arguments.

Parameters
...args Args forwarded to the object constructor.
Returns
A reference to the constructed element.

◆ empty()

template<typename T , typename Allocator = rfk::Allocator<T>>
bool rfk::Vector< T, Allocator >::empty ( ) const
noexcept

Check if the container contains no elements.

Returns
true if there are no elements in the vector, else false.

◆ end()

template<typename T , typename Allocator = rfk::Allocator<T>>
T * rfk::Vector< T, Allocator >::end ( )
noexcept

Get a pointer past the last element.

Returns
A pointer past the last element.

◆ front()

template<typename T , typename Allocator = rfk::Allocator<T>>
T & rfk::Vector< T, Allocator >::front ( )
noexcept

Get a reference to the first element of the vector. The behaviour is undefined if the vector is empty.

Returns
A reference to the first element of the vector.

◆ insert() [1/2]

template<typename T , typename Allocator = rfk::Allocator<T>>
void rfk::Vector< T, Allocator >::insert ( std::size_t  index,
T &&  element 
)

Insert an element at a specified index.

Parameters
indexIndex of the element in the vector.
elementElement to insert.

◆ insert() [2/2]

template<typename T , typename Allocator = rfk::Allocator<T>>
void rfk::Vector< T, Allocator >::insert ( std::size_t  index,
T const &  element 
)

Insert an element at a specified index.

Parameters
indexIndex of the element in the vector.
elementElement to insert.

◆ operator[]()

template<typename T , typename Allocator = rfk::Allocator<T>>
T & rfk::Vector< T, Allocator >::operator[] ( std::size_t  index)
noexcept

Access the index(th) element in the vector.

Parameters
indexIndex of the element to access.
Returns
A reference to the index(th) element in the vector.

◆ push_back() [1/3]

template<typename T , typename Allocator = rfk::Allocator<T>>
void rfk::Vector< T, Allocator >::push_back ( T &&  value)

Add an element to the vector.

Parameters
valueThe object to forward.

◆ push_back() [2/3]

template<typename T , typename Allocator = rfk::Allocator<T>>
void rfk::Vector< T, Allocator >::push_back ( T const &  value)

Add an element to the vector.

Parameters
valueThe object to copy.

◆ push_back() [3/3]

template<typename T , typename Allocator = rfk::Allocator<T>>
void rfk::Vector< T, Allocator >::push_back ( Vector< T, Allocator > const &  other)

Add all elements from a vector at the end of this vector.

Parameters
otherThe vector which elements must be copied.

◆ reserve()

template<typename T , typename Allocator = rfk::Allocator<T>>
void rfk::Vector< T, Allocator >::reserve ( std::size_t  capacity)

Reallocate the underlying memory to have enough space to fit capacity elements. No reallocation happens if the provided capacity is equal or smaller than the current capacity.

Parameters
capacityNew capacity.

◆ resize()

template<typename T , typename Allocator = rfk::Allocator<T>>
void rfk::Vector< T, Allocator >::resize ( std::size_t  size)

Resize the vector so that it has exactly the specified size. Reallocation occurs if the size is greater than the current capacity. Objects are default constructed if the specified size is greater than the current size.

Parameters
sizeThe new size.

◆ size()

template<typename T , typename Allocator = rfk::Allocator<T>>
std::size_t rfk::Vector< T, Allocator >::size ( ) const
noexcept

Get the number of elements stored in the vector.

Returns
The number of elements stored in the vector.

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