reinit(const Vector<Number, MemorySpace> &V,
const bool omit_zeroing_entries = false);
+ /**
+ * Swap the contents of this vector and the other vector @p v. One could do
+ * this operation with a temporary variable and copying over the data
+ * elements, but this function is significantly more efficient since it
+ * only swaps the pointers to the data of the two vectors and therefore
+ * does not need to allocate temporary storage and move data around.
+ *
+ * This function is analogous to the @p swap function of all C++
+ * standard containers. Also, there is a global function
+ * <tt>swap(u,v)</tt> that simply calls <tt>u.swap(v)</tt>, again in
+ * analogy to standard functions.
+ *
+ * This function is virtual in order to allow for derived classes to
+ * handle memory separately.
+ */
+ virtual void
+ swap(Vector &v);
+
/**
* Extract a range of elements all at once.
*/
/* ------------------------- Inline functions ---------------------- */
+ template <typename Number, typename MemorySpace>
+ inline void
+ swap(Vector<Number, MemorySpace> &u, Vector<Number, MemorySpace> &v)
+ {
+ u.swap(v);
+ }
+
+
template <typename Number, typename MemorySpace>
inline bool
Vector<Number, MemorySpace>::has_ghost_elements() const
return compressed;
}
+ template <typename Number, typename MemorySpace>
+ inline void
+ Vector<Number, MemorySpace>::swap(Vector<Number, MemorySpace> &v)
+ {
+ vector.swap(v.vector);
+ }
template <typename Number, typename MemorySpace>