2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef containertricks_h
24 #define containertricks_h
42 vlinit_t(const vlinit_t
<C
> &ci
);
43 vlinit_t
<C
> add(typename
C::value_type v
);
44 vlinit_t
<C
> operator=(typename
C::value_type v
) { return add(v
); };
45 vlinit_t
<C
> operator,(typename
C::value_type v
) { return add(v
); };
49 inline vlinit_t
<C
>::vlinit_t(const vlinit_t
<C
> &ci
)
55 inline vlinit_t
<C
>::vlinit_t(C
&a_c
)
61 inline vlinit_t
<C
> vlinit_t
<C
>::add(typename
C::value_type v
)
67 template <class C
> inline vlinit_t
<C
> vlinit(C
&c
) { return vlinit_t
<C
>(c
); };
77 typename
C::iterator i
;
81 clinit_t(const clinit_t
<C
> &ci
);
82 clinit_t
<C
> add(typename
C::value_type v
);
83 clinit_t
<C
> operator=(typename
C::value_type v
) { return add(v
); };
84 clinit_t
<C
> operator,(typename
C::value_type v
) { return add(v
); };
88 inline clinit_t
<C
>::clinit_t(const clinit_t
<C
> &ci
)
95 inline clinit_t
<C
>::clinit_t(C
&a_c
)
102 inline clinit_t
<C
> clinit_t
<C
>::add(typename
C::value_type v
)
105 cerr
<< "array bounds exceeded" << endl
;
113 template <class C
> inline clinit_t
<C
> clinit(C
&c
) { return clinit_t
<C
>(c
); };
116 inline void clinit(C
&c
, typename
C::value_type v
, ...)
118 if (c
.size() == 0) return;
119 typename
C::iterator i
= c
.begin();
125 while (v
= va_arg(vl
,typename
C::value_type
)) {
127 cerr
<< "array bounds exceeded" << endl
;
142 inline void simple_print(const C
&c
, ostream
&s
)
144 typename
C::const_iterator i
= c
.begin();
146 while (i
!= c
.end()) {
149 if (i
!= c
.end()) s
<< ", ";
155 inline void print_table(vector
<vector
<double> > f
, ostream
&s
)
157 size_t Nj
= f
[0].size();
158 for (size_t j
= 0; j
< Nj
; j
++) {
159 for (size_t i
= 0; i
< f
.size(); i
++) {
160 s
.setf(iostream::scientific
, iostream::floatfield
);
169 inline void print_table(vector
<vector
<double> > f
, string file_name
)
172 ofstream
s(file_name
.c_str());