for_each_group_t.cc
Go to the documentation of this file.
6 
7 #include <list>
8 #include <string>
9 #include <vector>
10 
11 using intvec_t = std::vector<int>;
12 using shortvec_t = std::vector<short>;
13 using strvec_t = std::vector<std::string>;
14 using floatvec_t = std::vector<float>;
18 
19 int
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...
assns_abd_t::const_iterator ci_t
std::vector< short > shortvec_t
static constexpr double fs
Definition: Units.h:100
int main()
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
std::vector< std::string > strvec_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
typename art::const_AssnsIter< L, R, D, Direction::Forward > const_iterator
Definition: Assns.h:237
#define a1