Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 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 // 7 // 26 // G4OrderedTable << 8 // $Id: G4OrderedTable.hh,v 1.7 2001/03/06 15:56:47 gcosmo Exp $ >> 9 // GEANT4 tag $Name: geant4-03-01 $ 27 // 10 // 28 // Class description: << 11 // >> 12 // ------------------------------------------------------------ >> 13 // GEANT 4 class header file >> 14 // ------------------------------------------------------------ >> 15 // Sep. 1996 : M.Maire >> 16 // Jan. 2001 : H.Kurashige >> 17 // - G4ValVector is replaced with G4DataVector >> 18 // - Migrated to G4std::vector<G4DataVector*>. 29 // 19 // 30 // Utility class, defining an ordered collecti << 20 // Class Description: >> 21 // >> 22 // Utility class, defining an ordered collection of vectors >> 23 // of <G4double>. 31 24 32 // Author: M.Maire (LAPP), September 1996 << 25 // ------------------------------------------------------------ 33 // Revisions: H.Kurashige (Kobe Univ.), Januar << 34 // ------------------------------------------- << 35 #ifndef G4OrderedTable_hh << 36 #define G4OrderedTable_hh 1 << 37 26 38 #include <vector> << 27 #ifndef G4OrderedTable_h >> 28 #define G4OrderedTable_h 1 39 29 40 #include "G4DataVector.hh" << 41 #include "globals.hh" 30 #include "globals.hh" >> 31 #include "g4std/vector" >> 32 #include "G4DataVector.hh" 42 33 43 class G4OrderedTable : public std::vector<G4Da << 34 class G4OrderedTable : public G4std::vector<G4DataVector*> 44 { 35 { 45 public: << 46 G4OrderedTable() = default; << 47 // Default constructor << 48 36 49 explicit G4OrderedTable(std::size_t cap); << 37 public: // with description 50 // Constructor given a 'capacity' defining t << 51 // number of elements (NULL pointers are fil << 52 38 53 virtual ~G4OrderedTable() = default; << 39 G4OrderedTable(); 54 // Empty Destructor << 40 // Deafult constructor. 55 41 56 void clearAndDestroy(); << 42 G4OrderedTable(size_t capacity); 57 // Removes all elements and deletes all non- << 43 // Constructor given a 'capacity' defining the initial >> 44 // number of elements (NULL pointers are filled up) 58 45 59 G4bool Store(const G4String& filename, G4boo << 46 virtual ~G4OrderedTable(){;} 60 // Stores OrderedTable in a file (returns fa << 47 // Empty Destructor 61 48 62 G4bool Retrieve(const G4String& filename, G4 << 49 inline void clearAndDestroy(); 63 // Retrieves OrderedTable from a file (retur << 50 // Removes all elements and deletes all non-NULL pointers 64 51 65 friend std::ostream& operator<<(std::ostream << 66 }; 52 }; >> 53 >> 54 inline >> 55 G4OrderedTable::G4OrderedTable() >> 56 : G4std::vector<G4DataVector*>() >> 57 { >> 58 } >> 59 >> 60 inline >> 61 G4OrderedTable::G4OrderedTable(size_t capacity) >> 62 : G4std::vector<G4DataVector*>(capacity, (G4DataVector*)(0) ) >> 63 { >> 64 } >> 65 >> 66 inline >> 67 void G4OrderedTable::clearAndDestroy() >> 68 { >> 69 G4DataVector* a; >> 70 while (size()>0) { >> 71 a = back(); >> 72 pop_back(); >> 73 for (iterator i=begin(); i!=end(); i++){ >> 74 if (*i==a) { >> 75 erase(i); >> 76 i--; >> 77 } >> 78 } >> 79 if ( a ) delete a; >> 80 } >> 81 } >> 82 67 83 68 #endif 84 #endif 69 85