1 #ifndef art_Persistency_Common_CollectionUtilities_h 2 #define art_Persistency_Common_CollectionUtilities_h 74 #include "cetlib/map_vector.h" 75 #include "cetlib/metaprogramming.h" 78 #include <type_traits> 83 class EDProductGetter;
90 template <
typename T,
typename InIter,
void (T::*)(InIter, InIter)>
92 template <
typename T,
typename I>
94 template <
typename T,
typename I>
100 sizeof(has_two_arg_insert_helper<T, typename T::const_iterator>(0)) ==
104 template <
typename T,
108 RET (T::*)(OutIter, InIter, InIter)>
110 template <
typename T,
typename R,
typename O,
typename I>
112 template <
typename T,
typename R,
typename O,
typename I>
115 template <
typename T>
124 typename T::iterator,
130 template <
typename C>
139 template <
typename P>
151 template <
typename CONTAINER>
155 template <
typename CONTAINER>
160 template <
typename COLLECTION>
165 template <
typename COLLECTION,
typename OFFSETS>
171 template <
typename T>
176 template <
typename T,
typename OFFSETS>
189 template <
typename T>
193 template <
typename iterator>
202 template <
typename T>
211 template <
typename iterator>
224 getter = (*beg).productGetter();
227 if ((*i) !=
nullptr &&
228 !((*i)->productGetter() && (*i)->productGetter() == getter &&
229 (*i)->id().isValid() && (*i)->id() == id)) {
238 template <
typename CONTAINER>
243 out.insert(in.begin(), in.end());
247 template <
typename T>
249 using mv_t = cet::map_vector<T>;
256 for (
auto& pr : in) {
257 pr.first = cet::map_vector_key{pr.first.asInt() +
d};
259 out.insert(in.begin(), in.end());
266 template <
typename CONTAINER>
273 template <
typename CONTAINER>
277 out.insert(out.end(), in.begin(), in.end());
281 template <
typename COLLECTION>
286 typename COLLECTION::size_type total_size = 0;
287 for (
auto collptr : in) {
288 if (collptr !=
nullptr) {
289 total_size += collptr->size();
292 out.reserve(total_size);
293 for (
auto collptr : in) {
294 if (collptr !=
nullptr) {
301 template <
typename COLLECTION,
typename OFFSETS>
308 offsets.reserve(in.size());
309 typename COLLECTION::size_type current_offset{};
310 for (
auto collptr : in) {
311 if (collptr ==
nullptr)
315 offsets.push_back(current_offset);
316 current_offset += delta;
318 flattenCollections<COLLECTION>(
in, out);
322 template <
typename T>
331 <<
"Attempt to flatten incompatible PtrVectors " 332 <<
"referring to different ProductIDs.\n";
334 flattenCollections<PtrVector<T>>(
in, out);
338 template <
typename T,
typename OFFSETS>
348 <<
"Attempt to flatten incompatible PtrVectors " 349 <<
"referring to different ProductIDs.\n";
351 flattenCollections<PtrVector<T>>(
in, out, offsets);
static size_t offset(cet::map_vector< P > const &mv)
static size_t offset(C const &c)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void flattenCollections(std::vector< COLLECTION const * > const &in, COLLECTION &out)
no_tag has_three_arg_insert_helper(...)
static bool constexpr value
bool verifyPtrCollection(std::vector< art::PtrVector< T > const * > const &in)
static void concatenate(mv_t &out, mv_t in)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string value(boost::any const &)
static void concatenate(CONTAINER &out, CONTAINER const &in)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
no_tag has_two_arg_insert_helper(...)
std::enable_if_t< detail::has_two_arg_insert< CONTAINER >::value > concatContainers(CONTAINER &out, CONTAINER const &in)
cet::map_vector< T > mv_t