#include <deal.II/base/exceptions.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/parallel.h>
+#include <boost/serialization/array.hpp>
+#include <boost/serialization/split_member.hpp>
#include <cstring>
void insert_back (ForwardIterator begin,
ForwardIterator end);
+ /**
+ * Fills the vector with size() copies of the given input
+ */
+ void fill (const T &element);
+
/**
* Swaps the given vector with the calling vector.
*/
*/
size_type memory_consumption () const;
+ /**
+ * Write the data of this object to
+ * a stream for the purpose of serialization.
+ */
+ template <class Archive>
+ void save (Archive &ar, const unsigned int version) const;
+
+ /**
+ * Read the data of this object
+ * from a stream for the purpose of serialization.
+ */
+ template <class Archive>
+ void load (Archive &ar, const unsigned int version);
+
+ BOOST_SERIALIZATION_SPLIT_MEMBER()
+
private:
/**
AlignedVector<T>&
AlignedVector<T>::operator = (const AlignedVector<T> &vec)
{
- clear();
+ resize(0);
resize_fast (vec._end_data - vec._data);
internal::AlignedVectorMove<T> (vec._data, vec._end_data, _data, true);
return *this;
// now _size is set correctly, need to set the
// values
if (size_in > old_size)
- internal::AlignedVectorSet<T> (size_in-old_size, init,
- _data+old_size);
+ internal::AlignedVectorSet<T> (size_in-old_size, init, _data+old_size);
}
+template < class T >
+inline
+void
+AlignedVector<T>::fill (const T &value)
+{
+ internal::AlignedVectorSet<T> (size(), value, _data);
+}
+
+
+
template < class T >
inline
void
+template < class T >
+template < class Archive >
+inline
+void
+AlignedVector<T>::save (Archive &ar, const unsigned int) const
+{
+ size_type vec_size (size());
+ ar &vec_size;
+ if (vec_size > 0)
+ ar &boost::serialization::make_array(_data, vec_size);
+}
+
+
+
+template < class T >
+template < class Archive >
+inline
+void
+AlignedVector<T>::load (Archive &ar, const unsigned int)
+{
+ size_type vec_size = 0;
+ ar &vec_size ;
+
+ if (vec_size > 0)
+ {
+ reserve(vec_size);
+ ar &boost::serialization::make_array(_data, vec_size);
+ _end_data = _data + vec_size;
+ }
+}
+
+
+
template < class T >
inline
typename AlignedVector<T>::size_type
:
Subscriptor ()
{
- reinit (src.table_size);
- if (src.n_elements() != 0)
- internal::AlignedVectorMove<T> (const_cast<T*>(src.values.begin()),
- const_cast<T*>(src.values.end()),
- values.begin(),
- true);
+ values = src.values;
+ reinit (src.table_size, true);
}
TableBase<N,T> &
TableBase<N,T>::operator = (const TableBase<N,T> &m)
{
- reinit (m.size());
- if (!empty())
- internal::AlignedVectorMove<T> (const_cast<T*>(m.values.begin()),
- const_cast<T*>(m.values.end()),
- values.begin(),
- true);
+ if (!m.empty())
+ values = m.values;
+ reinit (m.size(), true);
return *this;
}
{
// use parallel set operation
if (n_elements() != 0)
- dealii::internal::AlignedVectorSet<T> (values.size(), T(),
- values.begin());
+ values.fill(T());
}
TableBase<N,T>::fill (const T &value)
{
if (n_elements() != 0)
- dealii::internal::AlignedVectorSet<T> (values.size(), value,
- values.begin());
+ values.fill(value);
}
// not fast resize, zero out all values)
values.resize_fast (new_size);
if (!fast)
- dealii::internal::AlignedVectorSet<T> (values.size(), T(),
- values.begin());
+ values.fill(T());
}