dune-common
2.2.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
common
dynvector.hh
Go to the documentation of this file.
1
// $Id: fvector.hh 6105 2010-08-25 16:06:36Z christi $
2
#ifndef DUNE_DYNVECTOR_HH
3
#define DUNE_DYNVECTOR_HH
4
5
#include<cmath>
6
#include<cstddef>
7
#include<cstdlib>
8
#include<complex>
9
#include<cstring>
10
#include<limits>
11
12
#include "
exceptions.hh
"
13
#include "
genericiterator.hh
"
14
15
#include <vector>
16
#include "
densevector.hh
"
17
18
namespace
Dune {
19
28
template
<
class
K >
class
DynamicVector;
29
template
<
class
K >
30
struct
DenseMatVecTraits
<
DynamicVector
<K> >
31
{
32
typedef
DynamicVector<K>
derived_type
;
33
typedef
std::vector<K>
container_type
;
34
typedef
K
value_type
;
35
typedef
typename
container_type::size_type
size_type
;
36
};
37
38
template
<
class
K >
39
struct
FieldTraits
<
DynamicVector
<K> >
40
{
41
typedef
typename
FieldTraits<K>::field_type
field_type
;
42
typedef
typename
FieldTraits<K>::real_type
real_type
;
43
};
44
49
template
<
class
K >
50
class
DynamicVector
:
public
DenseVector
< DynamicVector<K> >
51
{
52
std::vector<K> _data;
53
54
typedef
DenseVector< DynamicVector<K>
>
Base
;
55
public
:
56
typedef
typename
Base::size_type
size_type
;
57
typedef
typename
Base::value_type
value_type
;
58
60
DynamicVector
() {}
61
63
explicit
DynamicVector
(
size_type
n,
value_type
c
=
value_type
() ) :
64
_data(n,
c
)
65
{}
66
68
DynamicVector
(
const
DynamicVector
& x) :
69
_data(x._data)
70
{}
71
72
using
Base::operator=;
73
74
//==== forward some methods of std::vector
79
size_type
capacity
()
const
80
{
81
return
_data.capacity();
82
}
83
void
resize
(
size_type
n,
value_type
c
=
value_type
() )
84
{
85
_data.resize(n,
c
);
86
}
87
void
reserve
(
size_type
n)
88
{
89
_data.reserve(n);
90
}
91
92
//==== make this thing a vector
93
size_type
vec_size
()
const
{
return
_data.size(); }
94
K &
vec_access
(
size_type
i) {
return
_data[i]; }
95
const
K &
vec_access
(
size_type
i)
const
{
return
_data[i]; }
96
};
97
109
template
<
class
K>
110
inline
std::istream &
operator>>
( std::istream &in,
111
DynamicVector<K>
&v )
112
{
113
DynamicVector<K>
w(v);
114
for
(
typename
DynamicVector<K>::size_type
i = 0; i < w.
size
(); ++i )
115
in >> w[ i ];
116
if
(in)
117
v = w;
118
return
in;
119
}
120
123
}
// end namespace
124
125
#endif
Generated on Tue Feb 26 2013 17:20:14 for dune-common by
1.8.1.2