1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #ifndef containertricks_h
22 #define containertricks_h
40 vlinit_t(const vlinit_t
<C
> &ci
);
41 vlinit_t
<C
> add(typename
C::value_type v
);
42 vlinit_t
<C
> operator=(typename
C::value_type v
) { return add(v
); };
43 vlinit_t
<C
> operator,(typename
C::value_type v
) { return add(v
); };
47 inline vlinit_t
<C
>::vlinit_t(const vlinit_t
<C
> &ci
)
53 inline vlinit_t
<C
>::vlinit_t(C
&a_c
)
59 inline vlinit_t
<C
> vlinit_t
<C
>::add(typename
C::value_type v
)
65 template <class C
> inline vlinit_t
<C
> vlinit(C
&c
) { return vlinit_t
<C
>(c
); };
75 typename
C::iterator i
;
79 clinit_t(const clinit_t
<C
> &ci
);
80 clinit_t
<C
> add(typename
C::value_type v
);
81 clinit_t
<C
> operator=(typename
C::value_type v
) { return add(v
); };
82 clinit_t
<C
> operator,(typename
C::value_type v
) { return add(v
); };
86 inline clinit_t
<C
>::clinit_t(const clinit_t
<C
> &ci
)
93 inline clinit_t
<C
>::clinit_t(C
&a_c
)
100 inline clinit_t
<C
> clinit_t
<C
>::add(typename
C::value_type v
)
103 cerr
<< "array bounds exceeded" << endl
;
111 template <class C
> inline clinit_t
<C
> clinit(C
&c
) { return clinit_t
<C
>(c
); };
114 inline void clinit(C
&c
, typename
C::value_type v
, ...)
116 if (c
.size() == 0) return;
117 typename
C::iterator i
= c
.begin();
123 while ((v
= va_arg(vl
,typename
C::value_type
))) {
125 cerr
<< "array bounds exceeded" << endl
;
140 inline void simple_print(const C
&c
, ostream
&s
)
142 typename
C::const_iterator i
= c
.begin();
144 while (i
!= c
.end()) {
147 if (i
!= c
.end()) s
<< ", ";
153 inline void print_table(vector
<vector
<double> > f
, ostream
&s
)
155 size_t Nj
= f
[0].size();
156 for (size_t j
= 0; j
< Nj
; j
++) {
157 for (size_t i
= 0; i
< f
.size(); i
++) {
158 s
.setf(iostream::scientific
, iostream::floatfield
);
167 inline void print_table(vector
<vector
<double> > f
, string file_name
)
170 ofstream
s(file_name
.c_str());