tlx
SimpleVector< ValueType, Mode > Class Template Reference

Simpler non-growing vector without initialization. More...

#include <simple_vector.hpp>

Public Types

using value_type = ValueType
 
using size_type = size_t
 
using iterator = value_type *
 
using const_iterator = const value_type *
 
using reference = value_type &
 
using const_reference = const value_type &
 

Public Member Functions

 SimpleVector ()
 allocate empty simple vector More...
 
 SimpleVector (const size_type &sz)
 allocate vector's memory More...
 
 SimpleVector (const SimpleVector &)=delete
 non-copyable: delete copy-constructor More...
 
SimpleVectoroperator= (const SimpleVector &)=delete
 non-copyable: delete assignment operator More...
 
 SimpleVector (SimpleVector &&v) noexcept
 move-constructor More...
 
SimpleVectoroperator= (SimpleVector &&v) noexcept
 move-assignment More...
 
void swap (SimpleVector &obj) noexcept
 swap vector with another one More...
 
 ~SimpleVector ()
 delete vector More...
 
iterator data () noexcept
 return iterator to beginning of vector More...
 
const_iterator data () const noexcept
 return iterator to beginning of vector More...
 
size_type size () const noexcept
 return number of items in vector More...
 
iterator begin () noexcept
 return mutable iterator to first element More...
 
const_iterator begin () const noexcept
 return constant iterator to first element More...
 
const_iterator cbegin () const noexcept
 return constant iterator to first element More...
 
iterator end () noexcept
 return mutable iterator beyond last element More...
 
const_iterator end () const noexcept
 return constant iterator beyond last element More...
 
const_iterator cend () const noexcept
 return constant iterator beyond last element More...
 
reference front () noexcept
 returns reference to the last element in the container More...
 
const_reference front () const noexcept
 returns reference to the first element in the container More...
 
reference back () noexcept
 returns reference to the first element in the container More...
 
const_reference back () const noexcept
 returns reference to the last element in the container More...
 
reference operator[] (size_type i) noexcept
 return the i-th position of the vector More...
 
const_reference operator[] (size_type i) const noexcept
 return constant reference to the i-th position of the vector More...
 
reference at (size_type i) noexcept
 return the i-th position of the vector More...
 
const_reference at (size_type i) const noexcept
 return constant reference to the i-th position of the vector More...
 
void resize (size_type new_size)
 resize the array to contain exactly new_size items More...
 
void destroy ()
 deallocate contained array More...
 
void fill (const value_type &v=value_type()) noexcept
 Zero the whole array content. More...
 

Protected Attributes

size_type size_
 size of allocated memory More...
 
value_typearray_
 pointer to allocated memory area More...
 

Static Private Member Functions

static ValueType * create_array (size_t size)
 
static void destroy_array (ValueType *array, size_t size)
 

Detailed Description

template<typename ValueType, SimpleVectorMode Mode = SimpleVectorMode::Normal>
class tlx::SimpleVector< ValueType, Mode >

Simpler non-growing vector without initialization.

SimpleVector can be used a replacement for std::vector when only a non-growing array of simple types is needed. The advantages of SimpleVector are that it does not initilize memory for POD types (-> faster), while normal structs are supported as well if default-contractible. The simple pointer types allow faster compilation and is less error prone to copying and other problems.

Definition at line 50 of file simple_vector.hpp.

Member Typedef Documentation

using const_iterator = const value_type *

Definition at line 67 of file simple_vector.hpp.

using const_reference = const value_type&

Definition at line 69 of file simple_vector.hpp.

using iterator = value_type *

Definition at line 66 of file simple_vector.hpp.

Definition at line 68 of file simple_vector.hpp.

using size_type = size_t

Definition at line 54 of file simple_vector.hpp.

using value_type = ValueType

Definition at line 53 of file simple_vector.hpp.

Constructor & Destructor Documentation

SimpleVector ( )
inline

allocate empty simple vector

Definition at line 73 of file simple_vector.hpp.

SimpleVector ( const size_type sz)
inlineexplicit

allocate vector's memory

Definition at line 78 of file simple_vector.hpp.

SimpleVector ( const SimpleVector< ValueType, Mode > &  )
delete

non-copyable: delete copy-constructor

SimpleVector ( SimpleVector< ValueType, Mode > &&  v)
inlinenoexcept

move-constructor

Definition at line 90 of file simple_vector.hpp.

~SimpleVector ( )
inline

delete vector

Definition at line 110 of file simple_vector.hpp.

Member Function Documentation

reference at ( size_type  i)
inlinenoexcept

return the i-th position of the vector

Definition at line 180 of file simple_vector.hpp.

const_reference at ( size_type  i) const
inlinenoexcept

return constant reference to the i-th position of the vector

Definition at line 184 of file simple_vector.hpp.

reference back ( )
inlinenoexcept

returns reference to the first element in the container

Definition at line 162 of file simple_vector.hpp.

const_reference back ( ) const
inlinenoexcept

returns reference to the last element in the container

Definition at line 166 of file simple_vector.hpp.

iterator begin ( )
inlinenoexcept

return mutable iterator to first element

Definition at line 128 of file simple_vector.hpp.

const_iterator begin ( ) const
inlinenoexcept

return constant iterator to first element

Definition at line 132 of file simple_vector.hpp.

const_iterator cbegin ( ) const
inlinenoexcept

return constant iterator to first element

Definition at line 136 of file simple_vector.hpp.

const_iterator cend ( ) const
inlinenoexcept

return constant iterator beyond last element

Definition at line 149 of file simple_vector.hpp.

static ValueType* create_array ( size_t  size)
inlinestaticprivate

Definition at line 216 of file simple_vector.hpp.

iterator data ( )
inlinenoexcept

return iterator to beginning of vector

Definition at line 115 of file simple_vector.hpp.

const_iterator data ( ) const
inlinenoexcept

return iterator to beginning of vector

Definition at line 119 of file simple_vector.hpp.

void destroy ( )
inline

deallocate contained array

Definition at line 204 of file simple_vector.hpp.

static void destroy_array ( ValueType *  array,
size_t  size 
)
inlinestaticprivate

Definition at line 231 of file simple_vector.hpp.

iterator end ( )
inlinenoexcept

return mutable iterator beyond last element

Definition at line 141 of file simple_vector.hpp.

const_iterator end ( ) const
inlinenoexcept

return constant iterator beyond last element

Definition at line 145 of file simple_vector.hpp.

void fill ( const value_type v = value_type())
inlinenoexcept

Zero the whole array content.

Definition at line 211 of file simple_vector.hpp.

reference front ( )
inlinenoexcept

returns reference to the last element in the container

Definition at line 154 of file simple_vector.hpp.

const_reference front ( ) const
inlinenoexcept

returns reference to the first element in the container

Definition at line 158 of file simple_vector.hpp.

SimpleVector& operator= ( const SimpleVector< ValueType, Mode > &  )
delete

non-copyable: delete assignment operator

SimpleVector& operator= ( SimpleVector< ValueType, Mode > &&  v)
inlinenoexcept

move-assignment

Definition at line 95 of file simple_vector.hpp.

reference operator[] ( size_type  i)
inlinenoexcept

return the i-th position of the vector

Definition at line 171 of file simple_vector.hpp.

const_reference operator[] ( size_type  i) const
inlinenoexcept

return constant reference to the i-th position of the vector

Definition at line 175 of file simple_vector.hpp.

void resize ( size_type  new_size)
inline

resize the array to contain exactly new_size items

Definition at line 189 of file simple_vector.hpp.

size_type size ( ) const
inlinenoexcept

return number of items in vector

Definition at line 123 of file simple_vector.hpp.

void swap ( SimpleVector< ValueType, Mode > &  obj)
inlinenoexcept

swap vector with another one

Definition at line 104 of file simple_vector.hpp.

Member Data Documentation

value_type* array_
protected

pointer to allocated memory area

Definition at line 61 of file simple_vector.hpp.

size_type size_
protected

size of allocated memory

Definition at line 58 of file simple_vector.hpp.


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