Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4OrderedTable << 27 // 23 // 28 // Class description: << 24 // $Id: G4OrderedTable.hh,v 1.7.2.1 2001/06/28 19:10:02 gunter Exp $ >> 25 // GEANT4 tag $Name: $ 29 // 26 // 30 // Utility class, defining an ordered collecti << 27 // >> 28 // ------------------------------------------------------------ >> 29 // GEANT 4 class header file >> 30 // ------------------------------------------------------------ >> 31 // Sep. 1996 : M.Maire >> 32 // Jan. 2001 : H.Kurashige >> 33 // - G4ValVector is replaced with G4DataVector >> 34 // - Migrated to G4std::vector<G4DataVector*>. >> 35 // >> 36 // Class Description: >> 37 // >> 38 // Utility class, defining an ordered collection of vectors >> 39 // of <G4double>. 31 40 32 // Author: M.Maire (LAPP), September 1996 << 41 // ------------------------------------------------------------ 33 // Revisions: H.Kurashige (Kobe Univ.), Januar << 34 // ------------------------------------------- << 35 #ifndef G4OrderedTable_hh << 36 #define G4OrderedTable_hh 1 << 37 42 38 #include <vector> << 43 #ifndef G4OrderedTable_h >> 44 #define G4OrderedTable_h 1 39 45 40 #include "G4DataVector.hh" << 41 #include "globals.hh" 46 #include "globals.hh" >> 47 #include "g4std/vector" >> 48 #include "G4DataVector.hh" 42 49 43 class G4OrderedTable : public std::vector<G4Da << 50 class G4OrderedTable : public G4std::vector<G4DataVector*> 44 { 51 { 45 public: << 46 G4OrderedTable() = default; << 47 // Default constructor << 48 52 49 explicit G4OrderedTable(std::size_t cap); << 53 public: // with description 50 // Constructor given a 'capacity' defining t << 51 // number of elements (NULL pointers are fil << 52 54 53 virtual ~G4OrderedTable() = default; << 55 G4OrderedTable(); 54 // Empty Destructor << 56 // Deafult constructor. 55 57 56 void clearAndDestroy(); << 58 G4OrderedTable(size_t capacity); 57 // Removes all elements and deletes all non- << 59 // Constructor given a 'capacity' defining the initial >> 60 // number of elements (NULL pointers are filled up) 58 61 59 G4bool Store(const G4String& filename, G4boo << 62 virtual ~G4OrderedTable(){;} 60 // Stores OrderedTable in a file (returns fa << 63 // Empty Destructor 61 64 62 G4bool Retrieve(const G4String& filename, G4 << 65 inline void clearAndDestroy(); 63 // Retrieves OrderedTable from a file (retur << 66 // Removes all elements and deletes all non-NULL pointers 64 67 65 friend std::ostream& operator<<(std::ostream << 66 }; 68 }; >> 69 >> 70 inline >> 71 G4OrderedTable::G4OrderedTable() >> 72 : G4std::vector<G4DataVector*>() >> 73 { >> 74 } >> 75 >> 76 inline >> 77 G4OrderedTable::G4OrderedTable(size_t capacity) >> 78 : G4std::vector<G4DataVector*>(capacity, (G4DataVector*)(0) ) >> 79 { >> 80 } >> 81 >> 82 inline >> 83 void G4OrderedTable::clearAndDestroy() >> 84 { >> 85 G4DataVector* a; >> 86 while (size()>0) { >> 87 a = back(); >> 88 pop_back(); >> 89 for (iterator i=begin(); i!=end(); i++){ >> 90 if (*i==a) { >> 91 erase(i); >> 92 i--; >> 93 } >> 94 } >> 95 if ( a ) delete a; >> 96 } >> 97 } >> 98 67 99 68 #endif 100 #endif 69 101