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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /analysis/accumulables/include/G4AccUnorderedMap.hh (Version 11.3.0) and /analysis/accumulables/include/G4AccUnorderedMap.hh (Version 11.1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26                                                   
 27 // Class template for accumulable unordered_ma    
 28 //                                                
 29 // Author: Ivana Hrivnacova, IJCLab IN2P3/CNRS    
 30                                                   
 31 #ifndef G4AccUnorderedMap_h                       
 32 #define G4AccUnorderedMap_h 1                     
 33                                                   
 34 #include "G4VAccumulable.hh"                      
 35 #include "G4MergeMode.hh"                         
 36                                                   
 37 #include "globals.hh"                             
 38                                                   
 39 #include <unordered_map>                          
 40                                                   
 41 template <class Key,                              
 42           class T,                                
 43           class Hash = std::hash<Key>,            
 44           class KeyEqual = std::equal_to<Key>,    
 45           class Allocator = std::allocator<std    
 46 class G4AccUnorderedMap : public G4VAccumulabl    
 47 {                                                 
 48   public:                                         
 49     // ctors to be supported                      
 50     // (https://en.cppreference.com/w/cpp/cont    
 51     //                                            
 52     // Default constructor (1) - Constructs an    
 53     // unordered_map();                           
 54     //                                            
 55     // Constructor (2) - Constructs an empty c    
 56     // explicit unordered_map( size_type bucke    
 57     //                         const Hash& has    
 58     //                         const KeyEqual&    
 59     //                         const Allocator    
 60     //                                            
 61     // Constructor (3) - Constructs an empty c    
 62     // unordered_map( size_type bucket_count,     
 63     //                const Allocator& alloc )    
 64     //   : unordered_map(bucket_count, Hash(),    
 65     //                                            
 66     // Constructor (4)  (since C++14)             
 67     // Constructs empty container.                
 68     // unordered_map( size_type bucket_count,     
 69     //                const Hash& hash,           
 70     //                const Allocator& alloc )    
 71     //     : unordered_map(bucket_count, hash,    
 72     //                                            
 73     // Constructor  (5) (since C++11)             
 74     // Constructs empty container.                
 75     // explicit unordered_map( const Allocator    
 76     //                                            
 77     // (6,7,8) (since C++11)                      
 78     // Constructs the container with the conte    
 79     // - skipped                                  
 80     //                                            
 81     // (9) (since C++11)  - Copy constructor.     
 82     // unordered_map( const unordered_map& oth    
 83     //                                            
 84     // (10) (since C++11) - Copy constructor w    
 85     // unordered_map( const unordered_map& oth    
 86     //                                            
 87     // (11)  (since C++11) - Move constructor.    
 88     // unordered_map( unordered_map&& other );    
 89     //                                            
 90     // (12)  (since C++11) - Move constructor     
 91     // unordered_map( unordered_map&& other, c    
 92     //                                            
 93     // (13)  (since C++11) - Initializer-list     
 94     // Constructs the container with the conte    
 95     // unordered_map( std::initializer_list<va    
 96     //                size_type bucket_count =    
 97     //                const Hash& hash = Hash(    
 98     //                const KeyEqual& equal =     
 99     //                const Allocator& alloc =    
100     //                                            
101     // (14)  (since C++11) - Initializer-list     
102     // Constructs the container with the conte    
103     // unordered_map( std::initializer_list<va    
104     //                size_type bucket_count,     
105     //                const Allocator& alloc )    
106     //     : unordered_map(init, bucket_count,    
107     //                     Hash(), KeyEqual(),    
108     //                                            
109     // (15)  (since C++14) - Initializer-list     
110     // unordered_map( std::initializer_list<va    
111     //                size_type bucket_count,     
112     //                const Hash& hash,           
113     //                const Allocator& alloc )    
114     //     : unordered_map(init, bucket_count,    
115     //                     hash, KeyEqual(), a    
116     //                                            
117     // (16,17)  (since C++23)                     
118     // Constructs the container with the conte    
119     // - skipped                                  
120                                                   
121                                                   
122     // Default constructor (1)                    
123     // Constructs an empty container with all     
124     G4AccUnorderedMap(const G4String& name = "    
125                       G4MergeMode mergeMode =     
126                                                   
127     // Constructor (2)                            
128     // Constructs an empty container with the     
129     G4AccUnorderedMap(std::size_t bucket_count    
130                       G4MergeMode mergeMode =     
131                       const Allocator& alloc =    
132                                                   
133     // Constructor (2) with name                  
134     // Constructs an empty container with the     
135     G4AccUnorderedMap(const G4String& name,       
136                       std::size_t bucket_count    
137                       G4MergeMode mergeMode =     
138                       const Allocator& alloc =    
139                                                   
140     // Constructor (3)                            
141     // Constructs an empty container with the     
142     G4AccUnorderedMap(std::size_t bucket_count    
143                       const Allocator& alloc,     
144                       G4MergeMode mergeMode =     
145                                                   
146     // Constructor (3) with name                  
147     // Constructs an empty container with the     
148     G4AccUnorderedMap(const G4String& name,       
149                       std::size_t bucket_count    
150                       const Allocator& alloc,     
151                       G4MergeMode mergeMode =     
152     // Constructor (4)                            
153     // Constructs an empty container with the     
154     G4AccUnorderedMap(std::size_t bucket_count    
155                       const Hash& hash,           
156                       const Allocator& alloc,     
157                       G4MergeMode mergeMode =     
158                                                   
159     // Constructor (4) with name                  
160     // Constructs an empty container with the     
161     G4AccUnorderedMap(const G4String& name,       
162                       std::size_t bucket_count    
163                       const Hash& hash,           
164                       const Allocator& alloc,     
165                       G4MergeMode mergeMode =     
166     // Constructor (5)                            
167     // Constructs an empty container with the     
168     G4AccUnorderedMap(const Allocator& alloc,     
169                       G4MergeMode mergeMode =     
170                                                   
171     // Constructor (5) with name                  
172     // Constructs an empty container with the     
173     G4AccUnorderedMap(const G4String& name,       
174                       const Allocator& alloc,     
175                       G4MergeMode mergeMode =     
176                                                   
177     // Constructor (13)                           
178     // Constructs the container with the conte    
179     G4AccUnorderedMap(std::initializer_list<st    
180                       G4MergeMode mergeMode =     
181                       std::size_t bucket_count    
182                       const Hash& hash = Hash(    
183                       const KeyEqual& equal =     
184                       const Allocator& alloc =    
185                                                   
186     // Constructor (13) with name                 
187     // Constructs the container with the conte    
188     G4AccUnorderedMap(const G4String& name,       
189                       std::initializer_list<st    
190                       G4MergeMode mergeMode =     
191                       std::size_t bucket_count    
192                       const Hash& hash = Hash(    
193                       const KeyEqual& equal =     
194                       const Allocator& alloc =    
195                                                   
196     // Copy constructor                           
197     G4AccUnorderedMap(const G4AccUnorderedMap&    
198     G4AccUnorderedMap(const G4AccUnorderedMap&    
199     // Move constructor                           
200     G4AccUnorderedMap(G4AccUnorderedMap&& rhs)    
201     G4AccUnorderedMap(G4AccUnorderedMap&& rhs,    
202                                                   
203     // Destructor                                 
204     ~G4AccUnorderedMap() override = default;      
205                                                   
206     // std::unordered_map functions, operators    
207     // operator []                                
208     inline T& operator[](const Key& key) { ret    
209     inline T& operator[](Key&& key) { return f    
210     // at                                         
211     inline T& at(const Key& key) { return fUMa    
212     inline const T& at(const Key& key ) const     
213     // size                                       
214     inline typename std::unordered_map<Key, T,    
215     // begin, cbegin                              
216     inline typename std::unordered_map<Key, T,    
217     inline typename std::unordered_map<Key, T,    
218     inline typename std::unordered_map<Key, T,    
219     // end, cend                                  
220     inline typename std::unordered_map<Key, T,    
221     inline typename std::unordered_map<Key, T,    
222     inline typename std::unordered_map<Key, T,    
223     // clear                                      
224     inline void clear() { fUMap.clear(); }        
225     // insert                                     
226     inline std::pair<typename std::unordered_m    
227     template< class P >                           
228     inline std::pair<typename std::unordered_m    
229     inline std::pair<typename std::unordered_m    
230     // find                                       
231     inline typename std::unordered_map<Key, T,    
232     inline typename std::unordered_map<Key, T,    
233                                                   
234     // Methods                                    
235     void Merge(const G4VAccumulable& other) fi    
236     void Reset() final;                           
237     void Print(G4PrintOptions options = G4Prin    
238     void SetMergeMode(G4MergeMode value) final    
239     void SetInitValue(const T& value);            
240                                                   
241     // Get methods                                
242     G4AccType GetType() const final { return G    
243     std::unordered_map<Key, T, Hash, KeyEqual,    
244     const std::unordered_map<Key, T, Hash, Key    
245                                                   
246   private:                                        
247     // Data members                               
248     std::unordered_map<Key, T, Hash, KeyEqual,    
249     T fInitValue = 0;                             
250     G4MergeFunction<T> fMergeFunction;            
251  };                                               
252                                                   
253 // inline functions                               
254                                                   
255 #include "G4AccUnorderedMap.icc"                  
256                                                   
257 #endif                                            
258