1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#ifndef DataFormats_Common_FillView_h
#define DataFormats_Common_FillView_h
/*----------------------------------------------------------------------
Several fillView function templates, to provide View support for
Standard Library containers.
----------------------------------------------------------------------*/
#include <vector>
#include <list>
#include <deque>
#include <set>
#include "DataFormats/Common/interface/GetProduct.h"
#include "DataFormats/Common/interface/FillViewHelperVector.h"
namespace edm {
class ProductID;
namespace detail {
template <class COLLECTION>
void reallyFillView(COLLECTION const& coll,
ProductID const& id,
std::vector<void const*>& ptrs,
FillViewHelperVector& helpers) {
typedef COLLECTION product_type;
typedef typename GetProduct<product_type>::element_type element_type;
typedef typename product_type::const_iterator iter;
typedef typename product_type::size_type size_type;
ptrs.reserve(ptrs.size() + coll.size());
helpers.reserve(ptrs.size() + coll.size());
size_type key = 0;
for (iter i = coll.begin(), e = coll.end(); i != e; ++i, ++key) {
element_type const* address = GetProduct<product_type>::address(i);
ptrs.push_back(address);
helpers.emplace_back(id, key);
}
}
} // namespace detail
template <class T, class A>
void fillView(std::vector<T, A> const& obj,
ProductID const& id,
std::vector<void const*>& ptrs,
FillViewHelperVector& helpers) {
detail::reallyFillView(obj, id, ptrs, helpers);
}
template <class T, class A>
void fillView(std::list<T, A> const& obj,
ProductID const& id,
std::vector<void const*>& ptrs,
FillViewHelperVector& helpers) {
detail::reallyFillView(obj, id, ptrs, helpers);
}
template <class T, class A>
void fillView(std::deque<T, A> const& obj,
ProductID const& id,
std::vector<void const*>& ptrs,
FillViewHelperVector& helpers) {
detail::reallyFillView(obj, id, ptrs, helpers);
}
template <class T, class A, class Comp>
void fillView(std::set<T, A, Comp> const& obj,
ProductID const& id,
std::vector<void const*>& ptrs,
FillViewHelperVector& helpers) {
detail::reallyFillView(obj, id, ptrs, helpers);
}
} // namespace edm
#endif
|