All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Static Public Member Functions | Private Types | Static Private Member Functions | List of all members
icarus::details::StableMerger< SetColl > Class Template Reference

Public Types

using SetColl_t = SetColl
 

Static Public Member Functions

static SetColl_t merge (SetColl_t const &sets)
 

Private Types

using Coll_t = typename SetColl_t::value_type
 
using Value_t = typename Coll_t::value_type
 

Static Private Member Functions

static bool addNewValue (Coll_t &coll, Value_t const &value)
 
static Coll_t mergeColls (Coll_t const &a, Coll_t const &b)
 
static bool overlap (Coll_t const &a, Coll_t const &b)
 
static SetColl_t mergePass (SetColl_t const &sets)
 

Detailed Description

template<typename SetColl>
class icarus::details::StableMerger< SetColl >

Definition at line 63 of file ROPandTPCsetBuildingAlg.cxx.

Member Typedef Documentation

template<typename SetColl >
using icarus::details::StableMerger< SetColl >::Coll_t = typename SetColl_t::value_type
private

Definition at line 76 of file ROPandTPCsetBuildingAlg.cxx.

template<typename SetColl >
using icarus::details::StableMerger< SetColl >::SetColl_t = SetColl

Definition at line 71 of file ROPandTPCsetBuildingAlg.cxx.

template<typename SetColl >
using icarus::details::StableMerger< SetColl >::Value_t = typename Coll_t::value_type
private

Definition at line 77 of file ROPandTPCsetBuildingAlg.cxx.

Member Function Documentation

template<typename SetColl >
bool icarus::details::StableMerger< SetColl >::addNewValue ( Coll_t coll,
Value_t const &  value 
)
staticprivate

Definition at line 99 of file ROPandTPCsetBuildingAlg.cxx.

100 {
101  if (std::find(coll.begin(), coll.end(), value) != coll.end()) return false;
102  coll.push_back(value);
103  return true;
104 } // icarus::details::StableMerger<>::mergeColls()
temporary value
template<typename SetColl >
auto icarus::details::StableMerger< SetColl >::merge ( SetColl_t const &  sets)
static

Definition at line 168 of file ROPandTPCsetBuildingAlg.cxx.

170 {
171  //
172  // do merging until no more overlap is detected (i.e. no merge is performed)
173  // (for example, if the sets are {0} {1} {0, 1}, the first pass will merge
174  // {0, 1} with {0} but the resulting sets {0, 1} {1} still overlap
175  //
176  SetColl_t mergedSets { sets };
177  std::size_t nSets;
178  do {
179 
180  nSets = mergedSets.size();
181 
182  mergedSets = mergePass(mergedSets);
183 
184  } while (mergedSets.size() != nSets);
185 
186  return mergedSets;
187 } // icarus::details::StableMerger<SetColl>::merge()
static SetColl_t mergePass(SetColl_t const &sets)
template<typename SetColl >
auto icarus::details::StableMerger< SetColl >::mergeColls ( Coll_t const &  a,
Coll_t const &  b 
)
staticprivate

Definition at line 110 of file ROPandTPCsetBuildingAlg.cxx.

111 {
112  Coll_t merged;
113  for (Value_t const& value: a) addNewValue(merged, value);
114  for (Value_t const& value: b) addNewValue(merged, value);
115  return merged;
116 } // icarus::details::StableMerger<>::mergeColls()
typename Coll_t::value_type Value_t
static bool addNewValue(Coll_t &coll, Value_t const &value)
process_name gaushit a
typename SetColl_t::value_type Coll_t
temporary value
template<typename SetColl >
auto icarus::details::StableMerger< SetColl >::mergePass ( SetColl_t const &  sets)
staticprivate

Definition at line 134 of file ROPandTPCsetBuildingAlg.cxx.

136 {
137 
138  SetColl_t mergedSets;
139  for (Coll_t const& set: sets) {
140 
141  //
142  // overlap check
143  //
144  Coll_t* mergeWith = nullptr;
145  for (Coll_t& mergedSet: mergedSets) {
146  if (!overlap(mergedSet, set)) continue;
147  mergeWith = &mergedSet;
148  break;
149  }
150 
151  if (mergeWith) {
152  *mergeWith = (mergeWith->size() < set.size())
153  ? mergeColls(set, *mergeWith)
154  : mergeColls(*mergeWith, set)
155  ;
156  }
157  else {
158  mergedSets.push_back(set);
159  }
160 
161  } // for input sets
162  return mergedSets;
163 } // icarus::details::StableMerger<>::mergePass()
static bool overlap(Coll_t const &a, Coll_t const &b)
typename SetColl_t::value_type Coll_t
static Coll_t mergeColls(Coll_t const &a, Coll_t const &b)
template<typename SetColl >
bool icarus::details::StableMerger< SetColl >::overlap ( Coll_t const &  a,
Coll_t const &  b 
)
staticprivate

Definition at line 122 of file ROPandTPCsetBuildingAlg.cxx.

123 {
124  // brute force since we can't assume ordering
125  for (auto const& aElem: a) {
126  if (std::find(b.begin(), b.end(), aElem) != b.end()) return true;
127  } // for
128  return false;
129 } // icarus::details::StableMerger<>::overlap()
process_name gaushit a

The documentation for this class was generated from the following file: