OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE > Class Template Reference

Container is a std::vector inspired data wrapper that allows for simple content manipulation of its owned data. More...

#include <container.h>

+ Inheritance diagram for olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >:
+ Collaboration diagram for olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >:

Public Member Functions

 Container ()
 
 Container (size_type count)
 
constexpr auto & at ()
 
FIELD_ARRAY_TYPE & data ()
 
constexpr bool empty ()
 
constexpr size_type size ()
 
constexpr size_type max_size ()
 
constexpr void reserve (size_type new_capacity)
 
constexpr size_type capacity ()
 
constexpr void shrink_to_fit ()
 
constexpr void clear ()
 
constexpr void erase (size_type i)
 
constexpr void push_back ()
 
template<typename COMMUNICATABLE >
void push_back (std::uint8_t *buffer)
 
template<typename INTERFACE >
void push_back (INTERFACE &interface)
 
constexpr void pop_back ()
 
void resize (size_type new_capacity)
 
void swapElements (size_type i, size_type j)
 
constexpr size_type getExtent ()
 

Detailed Description

template<typename T, typename DESCRIPTOR, typename FIELD_ARRAY_TYPE>
class olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >

Container is a std::vector inspired data wrapper that allows for simple content manipulation of its owned data.

FieldArrayD, AnyFieldArrayD, MultiFieldArrayD and DynamicFieldGroupsD do handle crucial data operations but do not provide simple access and manipulation functions as e.g. provided in std:: containers such as size and capacity handling. This Container class applicable to a provided FIELD_ARRAY_TYPE adds this functionality. It is also intended to be a crucial part in the parallization refactoring of the particle system by replacing the currently used std::deque container.

Definition at line 44 of file container.h.

Constructor & Destructor Documentation

◆ Container() [1/2]

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::Container ( )
inline

Definition at line 51 of file container.h.

51 :
52 _data(FIELD_ARRAY_TYPE(size_type(0))),_size(size_type(0)) { }

◆ Container() [2/2]

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::Container ( size_type count)
inline

Definition at line 54 of file container.h.

54 :
55 _data(FIELD_ARRAY_TYPE(count)),_size(count) { }

Member Function Documentation

◆ at()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr auto & olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::at ( )
constexpr

◆ capacity()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr size_type olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::capacity ( )
inlineconstexpr

Definition at line 74 of file container.h.

74{ return _data.count(); }
+ Here is the caller graph for this function:

◆ clear()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::clear ( )
constexpr

◆ data()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
FIELD_ARRAY_TYPE & olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::data ( )
inline

Definition at line 62 of file container.h.

62{ return _data; }

◆ empty()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr bool olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::empty ( )
constexpr

◆ erase()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::erase ( size_type i)
inlineconstexpr

Definition at line 82 of file container.h.

82 { //TODO: own prototype (check common!)
83 _data.swap(i, _size-1);
84 _size--;
85 }

◆ getExtent()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr size_type olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::getExtent ( )
inlineconstexpr

Definition at line 122 of file container.h.

122{ return _size; } //Analogy to lattice type (necessary for generic iteration)

◆ max_size()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr size_type olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::max_size ( )
constexpr

◆ pop_back()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::pop_back ( )
inlineconstexpr

Definition at line 113 of file container.h.

113{ _size--; }

◆ push_back() [1/3]

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::push_back ( )
inlineconstexpr

Definition at line 87 of file container.h.

87 {
88 if ( this->capacity()==this->size() ){
89 size_type new_capacity = 2*this->capacity();
90 if (this->capacity()==0){ new_capacity=1; }
91 this->resize( new_capacity );
92 }
93 _size++;
94 }
void resize(size_type new_capacity)
Definition container.h:115
constexpr size_type capacity()
Definition container.h:74
constexpr size_type size()
Definition container.h:68

References olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::capacity(), olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::resize(), and olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::size().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push_back() [2/3]

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
template<typename INTERFACE >
void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::push_back ( INTERFACE & interface)
inline

Definition at line 104 of file container.h.

104 {
105 const std::vector<unsigned int> indices{static_cast<unsigned int>(interface.getId())};
106 auto communicatable = interface.getCommunicatable();
107 int serialSize = communicatable.size(indices);
108 std::shared_ptr<std::uint8_t[]> buffer(new std::uint8_t[serialSize]{ });
109 communicatable.serialize(indices, buffer.get());
110 push_back<decltype(communicatable)>( buffer.get() );
111 }

◆ push_back() [3/3]

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
template<typename COMMUNICATABLE >
void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::push_back ( std::uint8_t * buffer)
inline

Definition at line 97 of file container.h.

97 {
98 push_back();
99 const std::vector<unsigned int> indices{(static_cast<unsigned int>(_size)-1)};
100 COMMUNICATABLE(_data).deserialize(indices, buffer);
101 }
constexpr void push_back()
Definition container.h:87

References olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::push_back().

+ Here is the call graph for this function:

◆ reserve()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::reserve ( size_type new_capacity)
constexpr

◆ resize()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::resize ( size_type new_capacity)
inline

Definition at line 115 of file container.h.

115{ _data.resize(new_capacity); }
+ Here is the caller graph for this function:

◆ shrink_to_fit()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::shrink_to_fit ( )
inlineconstexpr

Definition at line 76 of file container.h.

76{ _data.resize(_size); }

◆ size()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
constexpr size_type olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::size ( )
inlineconstexpr

Definition at line 68 of file container.h.

68{ return _size;}
+ Here is the caller graph for this function:

◆ swapElements()

template<typename T , typename DESCRIPTOR , typename FIELD_ARRAY_TYPE >
void olb::Container< T, DESCRIPTOR, FIELD_ARRAY_TYPE >::swapElements ( size_type i,
size_type j )
inline

Definition at line 117 of file container.h.

118 {
119 _data.swap(i, j);
120 }

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