Typedefs | Functions
const_assns_iter_t.cc File Reference
#include "canvas/Persistency/Common/Assns.h"
#include "canvas/Persistency/Common/AssnsIter.h"
#include "canvas/Persistency/Common/Ptr.h"
#include <algorithm>
#include <cassert>
#include <string>
#include <type_traits>
#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
 
using ab_node_t = assns_ab_t::const_iterator::value_type
 
using ab_node_first_t = ab_node_t::first_type
 
using ab_node_second_t = ab_node_t::second_type
 
using abd_node_t = ci_t::value_type
 
using abd_node_first_t = abd_node_t::first_type
 
using abd_node_second_t = abd_node_t::second_type
 
using abd_node_data_t = abd_node_t::data_type
 

Functions

int main ()
 

Typedef Documentation

using ab_node_first_t = ab_node_t::first_type

Definition at line 22 of file const_assns_iter_t.cc.

using ab_node_second_t = ab_node_t::second_type

Definition at line 23 of file const_assns_iter_t.cc.

using ab_node_t = assns_ab_t::const_iterator::value_type

Definition at line 21 of file const_assns_iter_t.cc.

using abd_node_data_t = abd_node_t::data_type

Definition at line 27 of file const_assns_iter_t.cc.

using abd_node_first_t = abd_node_t::first_type

Definition at line 25 of file const_assns_iter_t.cc.

using abd_node_second_t = abd_node_t::second_type

Definition at line 26 of file const_assns_iter_t.cc.

using abd_node_t = ci_t::value_type

Definition at line 24 of file const_assns_iter_t.cc.

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

Definition at line 17 of file const_assns_iter_t.cc.

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

Definition at line 18 of file const_assns_iter_t.cc.

Definition at line 19 of file const_assns_iter_t.cc.

using floatvec_t = std::vector<float>

Definition at line 16 of file const_assns_iter_t.cc.

using intvec_t = std::vector<int>

Definition at line 13 of file const_assns_iter_t.cc.

using shortvec_t = std::vector<short>

Definition at line 14 of file const_assns_iter_t.cc.

Definition at line 15 of file const_assns_iter_t.cc.

Function Documentation

int main ( void  )

Definition at line 37 of file const_assns_iter_t.cc.

38 {
39 
40  // initialization stuff
41  art::ProductID const viid{2};
42  art::ProductID const vfid{3};
43  intvec_t const vi{1, 2, 3};
44  floatvec_t const vf{1.0, 1.1, 2.0, 2.1, 3.0, 3.1};
45  shortvec_t const vs{10, 11, 20, 21, 30, 31};
46  intvec_t const vtest{1, 1, 2, 2, 3, 3};
47 
48  int k{};
49 
50  assns_abd_t assns;
51  assns_ab_t a1;
52 
53  for (long unsigned int i = 0; i < 3; ++i) {
54  auto p1 = art::Ptr<int>(viid, &vi[i], i);
55  for (long unsigned int j = 0; j < 2; ++j) {
56  auto p2 = art::Ptr<float>(vfid, &vf[k], k);
57  assns.addSingle(p1, p2, vs[k]);
58  a1.addSingle(p1, p2);
59  ++k;
60  }
61  }
62 
63  // iterator increment and dereference test
64  auto my_begin = assns.begin();
65  auto const my_end = assns.end();
66 
67  auto check_values =
68  [](auto const& r, short const s, float const f, int const j) {
69  auto const& first = get<abd_node_first_t>(r);
70  auto const& second = get<abd_node_second_t>(r);
71  auto const& data = get<abd_node_data_t>(r);
72 
73  auto const& firstA = get<0>(r);
74  auto const& secondA = get<1>(r);
75  auto const& dataA = get<2>(r);
76 
77  auto const& firstB = get<Ptr<int>>(r);
78  auto const& secondB = get<Ptr<float>>(r);
79  auto const& dataB = get<short>(r);
80 
81  assert(first == firstA);
82  assert(second == secondA);
83  assert(data == dataA);
84 
85  assert(first == firstB);
86  assert(second == secondB);
87  assert(data == dataB);
88 
89  assert(data == s);
90  assert(*second == f);
91  assert(*first == j);
92  };
93 
94  k = 0;
95  for (auto p = my_begin; p != my_end; ++p) {
96  auto const& r = *p;
97  check_values(r, vs[k], vf[k], vtest[k]);
98  ++k;
99  }
100 
101  // range-for loop test
102  k = 0;
103  for (auto const& p : assns) {
104  check_values(p, vs[k], vf[k], vtest[k]);
105  ++k;
106  }
107 
108  // std::for_each test
109  auto print = [](auto const& r) { std::cout << " " << *(r.data); };
110  std::for_each(assns.begin(), assns.end(), print);
111  std::cout << std::endl;
112 
113  static_assert(std::is_copy_constructible_v<ci_t>);
114  static_assert(std::is_copy_assignable_v<ci_t>);
115  static_assert(std::is_move_assignable_v<ci_t>);
116 
117  assert(*((*(my_begin + 4)).data) == 30);
118  my_begin += 4;
119  assert(*((*my_begin).data) == 30);
120  assert(my_begin - my_end == 2);
121  assert(*(my_begin[0].data) == 30);
122  assert(*(my_begin->data) == 30);
123  assert((my_begin < my_end) == true);
124  assert((my_begin <= my_end) == true);
125  assert((my_begin > my_end) == false);
126  assert((my_begin >= my_end) == false);
127 
128  // reverse iterator test
129  assns_abd_t empty_assns;
130  assert(empty_assns.rbegin() == empty_assns.rend());
131 
132  k = assns.size() - 1;
133  auto const my_rbegin = assns.rbegin();
134  auto const my_rend = assns.rend();
135  for (auto it = my_rbegin; it != my_rend; ++it) {
136  check_values(*it, vs[k], vf[k], vtest[k]);
137  --k;
138  }
139 
140  assert((my_rbegin < my_rend) == true);
141  assert((my_rbegin <= my_rend) == true);
142  assert((my_rbegin > my_rend) == false);
143  assert((my_rbegin >= my_rend) == false);
144 
145  return 0;
146 }
std::vector< short > shortvec_t
const_iterator begin() const
Definition: Assns.h:504
std::vector< int > intvec_t
std::vector< float > floatvec_t
p
Definition: test.py:223
const_iterator end() const
Definition: Assns.h:511
const_reverse_iterator rend() const
Definition: Assns.h:525
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:546
const_reverse_iterator rbegin() const
Definition: Assns.h:518
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
Definition: fwd.h:31
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)
#define a1