Flow123d  DF_patch_fe_data_tables-dc3adc1
Public Member Functions | Private Attributes | List of all members
RevertableList< Type > Struct Template Reference

Struct is a container that encapsulates variable size arrays. More...

#include <revertable_list.hh>

Collaboration diagram for RevertableList< Type >:
Collaboration graph
[legend]

Public Member Functions

 RevertableList (std::size_t reserved_size, std::size_t enlarged_by=0)
 Constructor, create new instance with reserved size. More...
 
 RevertableList (const RevertableList &other)
 Copy constructor. More...
 
void resize (std::size_t new_size)
 
std::size_t permanent_size () const
 Return permanent size of list. More...
 
std::size_t temporary_size () const
 Return temporary size of list (full size of stored data). More...
 
std::size_t reserved_size () const
 Return reserved (maximal) size. More...
 
std::size_t push_back (const Type &t)
 
template<class... Args>
std::size_t emplace_back (Args &&... args)
 
std::size_t make_permanent ()
 Finalize temporary part of data. More...
 
std::size_t revert_temporary ()
 Erase temporary part of data. More...
 
void reset ()
 Clear the list. More...
 
std::vector< Type >::iterator begin ()
 
std::vector< Type >::iterator end ()
 
const Type & operator[] (std::size_t pos) const
 Return item on given position. More...
 

Private Attributes

std::vector< Type > data_
 Vector of items. More...
 
std::size_t temporary_size_
 Temporary size (full size of used data). More...
 
std::size_t permanent_size_
 Final size of data (part of finalize data). More...
 
std::size_t enlarged_by_
 Allow to enlarge list dynamically during call push_back if reserved size is full. More...
 

Detailed Description

template<class Type>
struct RevertableList< Type >

Struct is a container that encapsulates variable size arrays.

Allows to:

  1. Add new items to container (method push_back, items are stored as temporary.
  2. Mark block of temporary items as final (use method make_permanent) or cancelled temporary item (method revert_temporary)

This algorith allows to add blocks of data, evaluates external condition and possibly reverts unfinished block if condition is not met.

Reserved (maximal) size is set in constructor. This size can be enlarged manually through method resize or constructor accepts parameter enlarged_by. If this value is greater than 0 size of container is automatically enlarged during call push_back if container is full.

Definition at line 43 of file revertable_list.hh.

Constructor & Destructor Documentation

◆ RevertableList() [1/2]

template<class Type >
RevertableList< Type >::RevertableList ( std::size_t  reserved_size,
std::size_t  enlarged_by = 0 
)
inline

Constructor, create new instance with reserved size.

Definition at line 46 of file revertable_list.hh.

◆ RevertableList() [2/2]

template<class Type >
RevertableList< Type >::RevertableList ( const RevertableList< Type > &  other)
inline

Copy constructor.

Definition at line 53 of file revertable_list.hh.

Member Function Documentation

◆ begin()

template<class Type >
std::vector<Type>::iterator RevertableList< Type >::begin ( )
inline

Definition at line 149 of file revertable_list.hh.

Here is the caller graph for this function:

◆ emplace_back()

template<class Type >
template<class... Args>
std::size_t RevertableList< Type >::emplace_back ( Args &&...  args)
inline

Create new item in list.

New item is created at the end of list and temporary size value is incremented. Method is equivalent with std::vector::emplace_back(). Method passes argumets of Type constructor.

Definition at line 114 of file revertable_list.hh.

Here is the caller graph for this function:

◆ end()

template<class Type >
std::vector<Type>::iterator RevertableList< Type >::end ( )
inline

Definition at line 154 of file revertable_list.hh.

Here is the caller graph for this function:

◆ make_permanent()

template<class Type >
std::size_t RevertableList< Type >::make_permanent ( )
inline

Finalize temporary part of data.

Definition at line 127 of file revertable_list.hh.

Here is the caller graph for this function:

◆ operator[]()

template<class Type >
const Type& RevertableList< Type >::operator[] ( std::size_t  pos) const
inline

Return item on given position.

Definition at line 160 of file revertable_list.hh.

◆ permanent_size()

template<class Type >
std::size_t RevertableList< Type >::permanent_size ( ) const
inline

Return permanent size of list.

Definition at line 71 of file revertable_list.hh.

Here is the caller graph for this function:

◆ push_back()

template<class Type >
std::size_t RevertableList< Type >::push_back ( const Type &  t)
inline

Add new item of list.

New item is added to end of list and temporary size value is incremented. Method is equivalent with std::vector::push_back(). This method needs to create copy of passed Type and it's beter to use emplace_back method.

Definition at line 95 of file revertable_list.hh.

◆ reserved_size()

template<class Type >
std::size_t RevertableList< Type >::reserved_size ( ) const
inline

Return reserved (maximal) size.

Definition at line 83 of file revertable_list.hh.

Here is the caller graph for this function:

◆ reset()

template<class Type >
void RevertableList< Type >::reset ( )
inline

Clear the list.

Definition at line 142 of file revertable_list.hh.

Here is the caller graph for this function:

◆ resize()

template<class Type >
void RevertableList< Type >::resize ( std::size_t  new_size)
inline

Resize to new reserved size.

New size must be higher than actual size!

Definition at line 64 of file revertable_list.hh.

Here is the caller graph for this function:

◆ revert_temporary()

template<class Type >
std::size_t RevertableList< Type >::revert_temporary ( )
inline

Erase temporary part of data.

Definition at line 134 of file revertable_list.hh.

Here is the caller graph for this function:

◆ temporary_size()

template<class Type >
std::size_t RevertableList< Type >::temporary_size ( ) const
inline

Return temporary size of list (full size of stored data).

Definition at line 77 of file revertable_list.hh.

Here is the caller graph for this function:

Member Data Documentation

◆ data_

template<class Type >
std::vector<Type> RevertableList< Type >::data_
private

Vector of items.

Definition at line 166 of file revertable_list.hh.

◆ enlarged_by_

template<class Type >
std::size_t RevertableList< Type >::enlarged_by_
private

Allow to enlarge list dynamically during call push_back if reserved size is full.

Definition at line 169 of file revertable_list.hh.

◆ permanent_size_

template<class Type >
std::size_t RevertableList< Type >::permanent_size_
private

Final size of data (part of finalize data).

Definition at line 168 of file revertable_list.hh.

◆ temporary_size_

template<class Type >
std::size_t RevertableList< Type >::temporary_size_
private

Temporary size (full size of used data).

Definition at line 167 of file revertable_list.hh.


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