49 #ifndef G4TAtomicHitsMap_h
50 #define G4TAtomicHitsMap_h 1
52 #include "G4THitsCollection.hh"
60 #include <type_traits>
77 "G4TAtomicHitsMap must use fundamental type");
83 typedef typename container_type::iterator
iterator;
154 template <
typename T>
159 template <
typename T>
166 template <
typename T>
169 for(
auto itr = theCollection->begin(); itr != theCollection->end(); itr++)
172 delete theCollection;
175 template <
typename T>
181 template <
typename T>
185 for(
auto itr = rhs.
GetMap()->begin(); itr != rhs.
GetMap()->end(); itr++)
186 add(itr->first, *(itr->second));
191 template <
typename T>
195 for(
auto itr = rhs.
GetMap()->begin(); itr != rhs.
GetMap()->end(); itr++)
196 add(itr->first, *(itr->second));
201 template <
typename T>
205 if(theCollection->find(key) != theCollection->end())
206 return theCollection->find(key)->second;
210 if(theCollection->find(key) == theCollection->end())
213 (*theCollection)[key] = ptr;
216 return theCollection->find(key)->second;
220 template <
typename T>
224 if(theCollection->find(key) != theCollection->end())
225 *(*theCollection)[key] += *aHit;
229 (*theCollection)[key] = aHit;
232 return theCollection->size();
235 template <
typename T>
240 if(theCollection->find(key) != theCollection->end())
241 *(*theCollection)[key] += aHit;
247 (*theCollection)[key] = hit;
250 return theCollection->size();
253 template <
typename T>
257 if(theCollection->find(key) != theCollection->end())
258 delete (*theCollection)[key]->second;
260 (*theCollection)[key] = aHit;
262 return theCollection->size();
265 template <
typename T>
269 if(theCollection->find(key) != theCollection->end())
270 *(*theCollection)[key] = aHit;
275 (*theCollection)[key] = hit;
278 return theCollection->size();
281 template <
typename T>
285 template <
typename T>
288 G4cout <<
"G4TAtomicHitsMap " << SDname <<
" / " << collectionName <<
" --- "
289 << entries() <<
" entries" <<
G4endl;
292 template <
typename T>
297 for(
auto itr = theCollection->begin(); itr != theCollection->end(); itr++)
300 theCollection->clear();
container_type::const_iterator const_iterator
container_type * GetMap() const
virtual ~G4TAtomicHitsMap()
container_type::iterator iterator
value_type * operator[](G4int key) const
container_type * theCollection
const_iterator end() const
std::map< G4int, mapped_type > container_type
virtual G4VHit * GetHit(size_t) const
virtual void PrintAllHits()
const XML_Char int const XML_Char * value
virtual void DrawAllHits()
virtual size_t GetSize() const
const_iterator find(G4int p) const
G4TAtomicHitsMap< T > & operator+=(const G4TAtomicHitsMap< T > &right) const
const_iterator cbegin() const
const_iterator begin() const
G4int operator==(const G4TAtomicHitsMap< T > &right) const
G4GLOB_DLL std::ostream G4cout
G4int add(const G4int &key, value_type *&aHit) const
const_iterator cend() const
G4int set(const G4int &key, value_type *&aHit) const
std::map< G4int, _Tp * > * GetMap() const
Definition of the G4atomic class.