1 #ifndef DUNE_FEM_COMMON_REFERENCEVECTOR_HH 2 #define DUNE_FEM_COMMON_REFERENCEVECTOR_HH 13 #include <dune/common/exceptions.hh> 14 #include <dune/common/densevector.hh> 15 #include <dune/common/nullptr.hh> 22 template<
class K,
class A = std::allocator< K* > >
27 template<
class K,
class A >
28 struct DenseMatVecTraits<
Fem::DynamicReferenceVector< K, A > >
31 typedef std::vector< K*, typename A::template rebind< K* >::other >
container_type;
34 typedef typename container_type::size_type
size_type;
37 template<
class K,
class A >
38 struct FieldTraits<
Fem::DynamicReferenceVector< K, A > >
40 typedef typename FieldTraits< K >::field_type
field_type;
41 typedef typename FieldTraits< K >::real_type
real_type;
60 template<
class K,
class A >
61 class DynamicReferenceVector :
public DenseVector< DynamicReferenceVector< K, A > >
63 typedef DynamicReferenceVector< K, A > This;
64 typedef DenseVector< DynamicReferenceVector < K, A > > Base;
66 typename DenseMatVecTraits< This > :: container_type data_;
78 : data_( n, nullptr, a )
82 : data_( other.data_ )
86 : data_(
std::
move( other.data_ ) )
90 using Base::operator=;
93 This & operator= (
const DenseVector< V > &other )
95 assert( data_.size() == other.size() );
96 std::copy( other.begin(), other.end(), Base::begin() );
100 This & operator= (
const This &other )
102 assert( data_.size() == other.size() );
103 std::copy( other.begin(), other.end(), Base::begin() );
107 This & operator= ( This &&other )
118 size_type
capacity ()
const {
return data_.capacity(); }
120 void resize ( size_type n ) { data_.resize( n,
nullptr ); }
121 void reserve ( size_type n ) { data_.reserve( n ); }
124 void bind ( size_type i, K& u ) { assert( i < data_.size() ); data_[ i ] = &u; }
125 void unbind ( size_type i ) { asssert( i < data_.size() ); data_[ i ] =
nullptr; }
128 size_type
vec_size ()
const {
return data_.size(); }
131 const K &
vec_access ( size_type i )
const {
return *data_[ i ]; }
141 #endif //#ifndef DUNE_FEM_COMMON_REFERENCEVECTOR_HH
const K & vec_access(size_type i) const
Definition: referencevector.hh:131
Base::size_type size_type
Definition: referencevector.hh:68
Fem::DynamicReferenceVector< K, A > derived_type
Definition: referencevector.hh:30
container_type::size_type size_type
Definition: referencevector.hh:34
K & vec_access(size_type i)
Definition: referencevector.hh:130
DynamicReferenceVector(This &&other)
Definition: referencevector.hh:85
size_type vec_size() const
Definition: referencevector.hh:128
DynamicReferenceVector(const A &a=A())
Constructor making uninitialized vector.
Definition: referencevector.hh:72
Construct a vector with a dynamic size.
Definition: referencevector.hh:23
DynamicReferenceVector(const This &other)
Definition: referencevector.hh:81
Base::value_type value_type
Definition: referencevector.hh:69
void unbind(size_type i)
Definition: referencevector.hh:125
std::vector< K *, typename A::template rebind< K * >::other > container_type
Definition: referencevector.hh:31
K value_type
Definition: referencevector.hh:33
void reserve(size_type n)
Definition: referencevector.hh:121
FieldTraits< K >::real_type real_type
Definition: referencevector.hh:41
Definition: coordinate.hh:4
void resize(size_type n)
Definition: referencevector.hh:120
FieldTraits< K >::field_type field_type
Definition: referencevector.hh:40
size_type capacity() const
Number of elements for which memory has been allocated.
Definition: referencevector.hh:118
DynamicReferenceVector(size_type n, const A &a=A())
Constructor making vector with identical coordinates.
Definition: referencevector.hh:77
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38
void bind(size_type i, K &u)
bind i-th entry to a reference
Definition: referencevector.hh:124