ATLAS Offline Software
Loading...
Searching...
No Matches
ProductGen.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "./ProductGen.h"
7
8
10
11ProductGen::ProductGen(const std::vector<std::size_t>& ends):
12 m_ends(ends), m_counters(ends.size(), 0), m_ncounters(ends.size()){
13
14 if (!m_ends.empty()){
15 m_done = false;
16 for(auto& i : m_ends){
17 if(i < 1) {
18 m_done = true;
19 break;
20 } else {
21 i -= 1;
22 }
23 }
24 }
25
26}
27
28
29std::vector<std::size_t> ProductGen::next() {
30
31 if(m_done){return std::vector<std::size_t>();}
32
33 auto result = std::vector<std::size_t>(m_counters);
34 m_done = atEnd();
35 for(std::size_t i = 0; i < m_ncounters; ++i){
36
37 if(m_counters[i] == m_ends[i]){
38 m_counters[i] = 0;
39 } else {
40 m_counters[i] += 1;
41 break;
42 }
43 }
44 return result;
45}
bool m_done
Definition ProductGen.h:25
std::size_t m_ncounters
Definition ProductGen.h:24
std::vector< std::size_t > next()
std::vector< std::size_t > m_counters
Definition ProductGen.h:23
std::vector< std::size_t > m_ends
Definition ProductGen.h:22
bool atEnd()
Definition ProductGen.h:26