Typedefs | Functions
for_each_group_t.cc File Reference
#include "canvas/Persistency/Common/Assns.h"
#include "canvas/Persistency/Common/AssnsAlgorithms.h"
#include "canvas/Persistency/Common/Ptr.h"
#include "canvas/Persistency/Common/PtrVector.h"
#include "canvas/Persistency/Provenance/ProductID.h"
#include <list>
#include <string>
#include <vector>

Go to the source code of this file.

Typedefs

using intvec_t = std::vector< int >
 
using shortvec_t = std::vector< short >
 
using strvec_t = std::vector< std::string >
 
using floatvec_t = std::vector< float >
 
using assns_ab_t = art::Assns< int, float >
 
using assns_abd_t = art::Assns< int, float, short >
 
using ci_t = assns_abd_t::const_iterator
 

Functions

int main ()
 

Typedef Documentation

using assns_ab_t = art::Assns<int, float>

Definition at line 15 of file for_each_group_t.cc.

using assns_abd_t = art::Assns<int, float, short>

Definition at line 16 of file for_each_group_t.cc.

Definition at line 17 of file for_each_group_t.cc.

using floatvec_t = std::vector<float>

Definition at line 14 of file for_each_group_t.cc.

using intvec_t = std::vector<int>

Definition at line 11 of file for_each_group_t.cc.

using shortvec_t = std::vector<short>

Definition at line 12 of file for_each_group_t.cc.

Definition at line 13 of file for_each_group_t.cc.

Function Documentation

int main ( void  )

Definition at line 20 of file for_each_group_t.cc.

21 {
22 
23  // initialization stuff
24  art::ProductID const viid{2};
25  art::ProductID const vfid{3};
26  intvec_t const vi{1, 2, 3};
27  floatvec_t const vf{1.0, 1.1, 2.0, 2.1, 3.0, 3.1};
28  shortvec_t const vs{10, 11, 20, 21, 30, 31};
29  intvec_t const vtest{1, 1, 2, 2, 3, 3};
30 
31  unsigned k{};
32 
33  assns_abd_t assns;
34  assns_ab_t a1;
35 
36  for (long unsigned int i = 0; i < 3; ++i) {
37  auto p1 = art::Ptr<int>(viid, &vi[i], i);
38  // Test addMany with different types of containers
40  std::list<short> data;
41  for (long unsigned int j = 0; j < 2; ++j) {
42  p2s.emplace_back(vfid, &vf[k], k);
43  data.push_back(vs[k]);
44  ++k;
45  }
46  assns.addMany(p1, p2s, data);
47  a1.addMany(p1, p2s);
48  }
49 
50  // use of art::for_each_group
51 
52  floatvec_t fvec;
53  auto floats = [&fvec](auto fs) {
54  for (auto f = begin(fs); f != end(fs); ++f) {
55  fvec.push_back(**f);
56  }
57  };
58 
59  art::for_each_group(a1, floats);
60  // floats should be same as vf
61  for (auto i = 0; i < 5; ++i) {
62  if (fvec[i] != vf[i]) {
64  << "Float #" << i << "expected to be '" << vf[i] << "', got '"
65  << fvec[i] << "' instead!\n";
66  }
67  }
68  return 0;
69 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::vector< short > shortvec_t
static constexpr double fs
Definition: Units.h:100
void addMany(Ls const &lefts, Ptr< right_t > const &right, Ds const &data)
Definition: Assns.h:557
std::vector< int > intvec_t
std::vector< float > floatvec_t
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void for_each_group(art::Assns< A, B, D > const &assns, F func)
Helper functions to access associations in order.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
Definition: fwd.h:31
#define a1