16 #if !defined(KRATOS_POINTER_VECTOR_H_INCLUDED )
17 #define KRATOS_POINTER_VECTOR_H_INCLUDED
29 #include <boost/iterator/indirect_iterator.hpp>
68 template<
class TDataType,
69 class TPointerType =
typename TDataType::Pointer,
70 class TContainerType = std::vector<TPointerType> >
89 typedef boost::indirect_iterator<typename TContainerType::iterator>
iterator;
90 typedef boost::indirect_iterator<typename TContainerType::const_iterator>
const_iterator;
91 typedef boost::indirect_iterator<typename TContainerType::reverse_iterator>
reverse_iterator;
94 typedef typename TContainerType::size_type
size_type;
108 template <
class TInputIteratorType>
116 explicit PointerVector(
const TContainerType& rContainer) : mData(rContainer)
133 mData = rOther.mData;
159 if(
size() != r.size() )
162 return std::equal(mData.begin(), mData.end(), r.mData.begin(), this->EqualKeyTo());
203 return mData.begin();
207 return mData.begin();
219 return mData.rbegin();
223 return mData.rbegin();
237 return *(mData.front());
242 return *(mData.front());
247 return *(mData.back());
252 return *(mData.back());
262 return mData.max_size();
267 mData.swap(rOther.mData);
277 mData.push_back(std::move(rX));
280 template<
class... Args>
283 mData.emplace_back(std::forward<Args>(
args)...);
288 return iterator(mData.insert(Position, pData));
291 template <
class InputIterator>
292 void insert(InputIterator First, InputIterator Last)
294 for(; First != Last; ++First)
301 return iterator(mData.erase(pos.base()));
306 return iterator( mData.erase( first.base(), last.base() ) );
326 return mData.capacity();
351 return mData.empty();
361 std::stringstream buffer;
362 buffer <<
"PointerVector (size = " <<
size() <<
") : ";
376 std::copy(
begin(),
end(), std::ostream_iterator<TDataType>(rOStream,
"\n "));
428 TContainerType mData;
445 virtual void save(
Serializer& rSerializer)
const
452 rSerializer.
save(
"E", mData[
i]);
464 rSerializer.
load(
"E", mData[
i]);
499 template<
class TDataType,
501 class TContainerType>
506 template<
class TDataType,
508 class TContainerType>
513 rOStream << std::endl;
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
TDataType & operator[](const size_type &i)
Definition: pointer_vector.h:137
void clear()
Definition: pointer_vector.h:309
const TPointerType const_pointer
Definition: pointer_vector.h:84
std::string Info() const
Turn back information as a string.
Definition: pointer_vector.h:359
KRATOS_CLASS_POINTER_DEFINITION(PointerVector)
Pointer definition of PointerVector.
const_reverse_iterator rbegin() const
Definition: pointer_vector.h:189
boost::indirect_iterator< typename TContainerType::const_reverse_iterator > const_reverse_iterator
Definition: pointer_vector.h:92
TContainerType::const_iterator ptr_const_iterator
Definition: pointer_vector.h:96
void swap(PointerVector &rOther)
Definition: pointer_vector.h:265
TContainerType ContainerType
Definition: pointer_vector.h:87
size_type size() const
Definition: pointer_vector.h:255
const_reference back() const
Definition: pointer_vector.h:249
int capacity()
Definition: pointer_vector.h:324
const_iterator end() const
Definition: pointer_vector.h:181
const_reference front() const
Definition: pointer_vector.h:239
ptr_const_reverse_iterator ptr_rend() const
Definition: pointer_vector.h:229
TDataType const & operator[](const size_type &i) const
Definition: pointer_vector.h:142
reverse_iterator rbegin()
Definition: pointer_vector.h:185
iterator erase(iterator pos)
Definition: pointer_vector.h:299
boost::indirect_iterator< typename TContainerType::reverse_iterator > reverse_iterator
Definition: pointer_vector.h:91
TContainerType::size_type size_type
Definition: pointer_vector.h:94
ptr_iterator ptr_end()
Definition: pointer_vector.h:209
TDataType value_type
Definition: pointer_vector.h:82
PointerVector(TInputIteratorType First, TInputIteratorType Last)
Definition: pointer_vector.h:109
ptr_const_iterator ptr_begin() const
Definition: pointer_vector.h:205
PointerVector(const PointerVector &rOther)
Definition: pointer_vector.h:114
iterator end()
Definition: pointer_vector.h:177
size_type max_size() const
Definition: pointer_vector.h:260
void reserve(size_type dim)
Definition: pointer_vector.h:319
ptr_reverse_iterator ptr_rbegin()
Definition: pointer_vector.h:217
ptr_const_reverse_iterator ptr_rbegin() const
Definition: pointer_vector.h:221
boost::indirect_iterator< typename TContainerType::const_iterator > const_iterator
Definition: pointer_vector.h:90
TPointerType pointer
Definition: pointer_vector.h:83
reference front()
Definition: pointer_vector.h:234
PointerVector & operator=(const PointerVector &rOther)
Definition: pointer_vector.h:131
const_iterator begin() const
Definition: pointer_vector.h:173
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector.h:89
reference back()
Definition: pointer_vector.h:244
TContainerType::const_reverse_iterator ptr_const_reverse_iterator
Definition: pointer_vector.h:98
const_reverse_iterator rend() const
Definition: pointer_vector.h:197
TContainerType::reverse_iterator ptr_reverse_iterator
Definition: pointer_vector.h:97
const TDataType & const_reference
Definition: pointer_vector.h:86
iterator erase(iterator first, iterator last)
Definition: pointer_vector.h:304
void push_back(TPointerType &&rX)
Definition: pointer_vector.h:275
ptr_const_iterator ptr_end() const
Definition: pointer_vector.h:213
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: pointer_vector.h:368
TContainerType::iterator ptr_iterator
Definition: pointer_vector.h:95
~PointerVector()
Destructor.
Definition: pointer_vector.h:125
TDataType data_type
data type stores in this container.
Definition: pointer_vector.h:81
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: pointer_vector.h:374
PointerVector(const TContainerType &rContainer)
Definition: pointer_vector.h:116
PointerVector()
Default constructor.
Definition: pointer_vector.h:106
void insert(InputIterator First, InputIterator Last)
Definition: pointer_vector.h:292
void emplace_back(Args &&... args)
Definition: pointer_vector.h:281
pointer & operator()(const size_type &i)
Definition: pointer_vector.h:147
TContainerType::difference_type difference_type
Definition: pointer_vector.h:99
const_pointer & operator()(const size_type &i) const
Definition: pointer_vector.h:152
ptr_reverse_iterator ptr_rend()
Definition: pointer_vector.h:225
iterator begin()
Definition: pointer_vector.h:169
bool operator==(const PointerVector &r) const
Definition: pointer_vector.h:157
PointerVector(std::size_t NewSize)
Definition: pointer_vector.h:120
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
TContainerType & GetContainer()
Definition: pointer_vector.h:334
bool empty() const
Definition: pointer_vector.h:349
const TContainerType & GetContainer() const
Definition: pointer_vector.h:340
iterator insert(iterator Position, const TPointerType pData)
Definition: pointer_vector.h:286
TDataType & reference
Definition: pointer_vector.h:85
reverse_iterator rend()
Definition: pointer_vector.h:193
ptr_iterator ptr_begin()
Definition: pointer_vector.h:201
void resize(size_type dim)
Definition: pointer_vector.h:314
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
args
Definition: generate_gid_list_file.py:37
int local_size
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:17
def load(f)
Definition: ode_solve.py:307
tuple const
Definition: ode_solve.py:403
x
Definition: sensitivityMatrix.py:49
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17