Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
util
test
test_mapvectorcopy.cxx
Go to the documentation of this file.
1
#include "
WireCellUtil/Testing.h
"
2
3
#include <cmath>
4
#include <map>
5
#include <vector>
6
#include <iostream>
7
8
typedef
std::vector<float>
sequence
;
9
typedef
std::map<int, sequence>
enumerated
;
10
11
using namespace
std
;
12
13
void
mutate
(
enumerated
& en)
14
{
15
en[0][0] = 42.0;
16
en[1][0] = 6.9;
17
}
18
19
bool
equal
(
double
a
,
double
b
)
20
{
21
if
(a == b) {
return
true
; }
22
23
return
std::abs
(a-b)/(a+
b
) < 0.0001;
24
}
25
26
int
main
() {
27
28
sequence
vec{1.0,2.0,3.0};
29
enumerated
stuff;
30
stuff[0] = vec;
31
stuff[1] = {10.0,20.0,30.0};
32
mutate
(stuff);
33
34
for
(
auto
iv : stuff) {
35
cerr << iv.first <<
":"
;
36
for
(
auto
x
: iv.second) {
37
cerr <<
" "
<<
x
;
38
}
39
cerr <<
endl
;
40
}
41
42
Assert
(
equal
(stuff[0][0], 42.0));
43
Assert
(
equal
(stuff[1][0], 6.9));
44
Assert
(
equal
(vec[0], 1.0));
45
46
return
0;
47
}
equal
bool equal(double a, double b)
Definition:
test_mapvectorcopy.cxx:19
std
STL namespace.
Assert
#define Assert
Definition:
Testing.h:7
main
int main()
Definition:
test_mapvectorcopy.cxx:26
abs
T abs(T value)
Definition:
sparse_vector_test.cc:30
Testing.h
a
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition:
pointer.h:1124
sequence
std::vector< float > sequence
Definition:
test_mapvectorcopy.cxx:8
b
static bool * b
Definition:
config.cpp:1043
train.x
list x
Definition:
train.py:276
mutate
void mutate(enumerated &en)
Definition:
test_mapvectorcopy.cxx:13
enumerated
std::map< int, sequence > enumerated
Definition:
test_mapvectorcopy.cxx:9
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11