Thrill  0.1
SimpleVector< ValueType, Mode > Class Template Reference

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.

+ Inheritance diagram for SimpleVector< ValueType, Mode >:

#include <simple_vector.hpp>

Public Types

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

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...
 
 SimpleVector (SimpleVector &&v) noexcept
 move-constructor More...
 
 ~SimpleVector ()
 delete 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...
 
const_iterator cend () const noexcept
 return constant iterator beyond last element More...
 
iterator data () noexcept
 return iterator to beginning of vector More...
 
const_iterator data () const noexcept
 return iterator to beginning of vector More...
 
void destroy ()
 deallocate contained array More...
 
iterator end () noexcept
 return mutable iterator beyond last element More...
 
const_iterator end () const noexcept
 return constant iterator beyond last element More...
 
void fill (const value_type &v=value_type()) noexcept
 Zero the whole array content. More...
 
SimpleVectoroperator= (const SimpleVector &)=delete
 non-copyable: delete assignment operator More...
 
SimpleVectoroperator= (SimpleVector &&v) noexcept
 move-assignment 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...
 
void resize (size_type new_size)
 resize the array to contain exactly new_size items More...
 
size_type size () const noexcept
 return number of items in vector More...
 
void swap (SimpleVector &obj) noexcept
 swap vector with another one More...
 

Protected Attributes

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

Static Private Member Functions

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

Member Typedef Documentation

◆ const_iterator

using const_iterator = const value_type *

Definition at line 67 of file simple_vector.hpp.

◆ const_reference

using const_reference = const value_type&

Definition at line 69 of file simple_vector.hpp.

◆ iterator

using iterator = value_type *

Definition at line 66 of file simple_vector.hpp.

◆ reference

Definition at line 68 of file simple_vector.hpp.

◆ size_type

using size_type = size_t

Definition at line 54 of file simple_vector.hpp.

◆ value_type

using value_type = ValueType

Definition at line 53 of file simple_vector.hpp.

Constructor & Destructor Documentation

◆ SimpleVector() [1/4]

SimpleVector ( )
inline

allocate empty simple vector

Definition at line 73 of file simple_vector.hpp.

◆ SimpleVector() [2/4]

SimpleVector ( const size_type sz)
inlineexplicit

allocate vector's memory

Definition at line 78 of file simple_vector.hpp.

◆ SimpleVector() [3/4]

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

non-copyable: delete copy-constructor

◆ SimpleVector() [4/4]

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

move-constructor

Definition at line 90 of file simple_vector.hpp.

◆ ~SimpleVector()

~SimpleVector ( )
inline

delete vector

Definition at line 110 of file simple_vector.hpp.

Member Function Documentation

◆ begin() [1/2]

◆ begin() [2/2]

const_iterator begin ( ) const
inlinenoexcept

return constant iterator to first element

Definition at line 132 of file simple_vector.hpp.

◆ cbegin()

const_iterator cbegin ( ) const
inlinenoexcept

return constant iterator to first element

Definition at line 136 of file simple_vector.hpp.

◆ cend()

const_iterator cend ( ) const
inlinenoexcept

return constant iterator beyond last element

Definition at line 149 of file simple_vector.hpp.

◆ create_array()

static ValueType* create_array ( size_t  size)
inlinestaticprivate

Definition at line 190 of file simple_vector.hpp.

◆ data() [1/2]

◆ data() [2/2]

const_iterator data ( ) const
inlinenoexcept

return iterator to beginning of vector

Definition at line 119 of file simple_vector.hpp.

◆ destroy()

◆ destroy_array()

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

Definition at line 205 of file simple_vector.hpp.

◆ end() [1/2]

◆ end() [2/2]

const_iterator end ( ) const
inlinenoexcept

return constant iterator beyond last element

Definition at line 145 of file simple_vector.hpp.

◆ fill()

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

Zero the whole array content.

Definition at line 185 of file simple_vector.hpp.

Referenced by block_manager::new_blocks().

◆ operator=() [1/2]

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

non-copyable: delete assignment operator

◆ operator=() [2/2]

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

move-assignment

Definition at line 95 of file simple_vector.hpp.

◆ operator[]() [1/2]

reference operator[] ( size_type  i)
inlinenoexcept

return the i-th position of the vector

Definition at line 154 of file simple_vector.hpp.

◆ operator[]() [2/2]

const_reference operator[] ( size_type  i) const
inlinenoexcept

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

Definition at line 158 of file simple_vector.hpp.

◆ resize()

◆ size()

◆ swap()

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

swap vector with another one

Definition at line 104 of file simple_vector.hpp.

Member Data Documentation

◆ array_

value_type* array_
protected

pointer to allocated memory area

Definition at line 61 of file simple_vector.hpp.

◆ size_

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: