28#ifndef G4MOLECULECOUNTERTEMPLATES_HH
29#define G4MOLECULECOUNTERTEMPLATES_HH 1
56 return std::binary_search(_set.cbegin(), _set.cend(), _value);
62 auto p = std::find(_vector.cbegin(), _vector.cend(), _value);
63 return p != _vector.cend();
66template<
typename T,
typename U>
75template<
typename T,
typename U>
78 std::vector<T> output;
79 for (
auto const& it : _map)
80 output.push_back(it.first);
89 G4cout <<
"--- BEGIN COUNTER MAP INDEX DUMP ---" <<
G4endl;
91 for (
auto const& it :
map) {
92 if (!includeEmpty && it.second.size() == 0)
continue;
95 G4cout <<
"--- END COUNTER MAP INDEX DUMP ---" <<
G4endl;
102 G4bool includeEmpty =
false)
105 for (
auto const& it :
map) {
106 if (!includeEmpty && it.second.size() == 0)
continue;
108 for (
auto const& it2 : it.second) {
109 G4cout << std::setw(3) << std::setprecision(3) <<
" " <<
G4BestUnit(it2.first,
"Time")
110 <<
" " << std::setw(5) << it2.second <<
G4endl;
121 std::set<G4double> output{};
122 for (
const auto& it :
map) {
124 for (
const auto& it2 : it.second) {
125 output.insert(it2.first);
133template<
typename TKey,
typename TValue,
typename TComp>
134typename std::map<TKey, TValue, TComp>::iterator
137 if (
map.empty())
return map.end();
139 auto it_lb =
map.lower_bound(key);
141 if (it_lb ==
map.begin())
return it_lb;
142 if (it_lb ==
map.end())
return --it_lb;
144 auto prev_it = std::prev(it_lb);
146 if (std::abs(it_lb->first - key) < std::abs(prev_it->first - key))
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4String GetTemplateTypeName()
void DumpCounterMapIndices(const std::map< T, InnerCounterMapType > &map, G4bool includeEmpty=false)
const std::vector< T > GetMapIndices(const std::map< T, U > &_map)
void DumpCounterMapContents(const std::map< T, InnerCounterMapType > &map, G4bool includeEmpty=false)
std::map< TKey, TValue, TComp >::iterator FindClosestEntryForKey(std::map< TKey, TValue, TComp > &map, TKey key)
std::set< G4double > GetRecordedTimes(const std::map< T, InnerCounterMapType > &map)
G4bool Contains(const std::set< T > &_set, const T &_value)
G4bool ContainsKey(const std::map< T, U > &_map, const T &_key)