Typedefs | Functions
test_mapvectorcopy.cxx File Reference
#include "WireCellUtil/Testing.h"
#include <cmath>
#include <map>
#include <vector>
#include <iostream>

Go to the source code of this file.

Typedefs

typedef std::vector< float > sequence
 
typedef std::map< int, sequenceenumerated
 

Functions

void mutate (enumerated &en)
 
bool equal (double a, double b)
 
int main ()
 

Typedef Documentation

typedef std::map<int, sequence> enumerated

Definition at line 9 of file test_mapvectorcopy.cxx.

typedef std::vector<float> sequence

Definition at line 8 of file test_mapvectorcopy.cxx.

Function Documentation

bool equal ( double  a,
double  b 
)

Definition at line 19 of file test_mapvectorcopy.cxx.

20 {
21  if (a == b) { return true; }
22 
23  return std::abs(a-b)/(a+b) < 0.0001;
24 }
T abs(T value)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
static bool * b
Definition: config.cpp:1043
int main ( void  )

Definition at line 26 of file test_mapvectorcopy.cxx.

26  {
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 }
bool equal(double a, double b)
#define Assert
Definition: Testing.h:7
std::vector< float > sequence
list x
Definition: train.py:276
void mutate(enumerated &en)
std::map< int, sequence > enumerated
QTextStream & endl(QTextStream &s)
void mutate ( enumerated en)

Definition at line 13 of file test_mapvectorcopy.cxx.

14 {
15  en[0][0] = 42.0;
16  en[1][0] = 6.9;
17 }