Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:05

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4DataVector
0027 //
0028 // Class description:
0029 //
0030 // Utility class providing similar behaviour of std::vector<G4double>.
0031 // It includes additional methods for compatibility with Rogue Wave
0032 // collection.
0033 
0034 // Author: H.Kurashige, 18 September 2001
0035 // --------------------------------------------------------------------
0036 #ifndef G4DataVector_hh
0037 #define G4DataVector_hh 1
0038 
0039 #include <fstream>
0040 #include <iostream>
0041 #include <vector>
0042 
0043 #include "G4ios.hh"
0044 #include "globals.hh"
0045 
0046 class G4DataVector : public std::vector<G4double>
0047 {
0048  public:
0049   G4DataVector() = default;
0050   // Default constructor.
0051 
0052   G4DataVector(const G4DataVector&) = default;
0053   G4DataVector(G4DataVector&&)      = default;
0054   // Default copy&move constructors.
0055 
0056   explicit G4DataVector(std::size_t cap);
0057   // Constructor given a 'capacity' defining the initial number of elements.
0058 
0059   G4DataVector(std::size_t cap, G4double value);
0060   // Constructor given a 'capacity' defining the initial number of elements
0061   // and initialising them to 'value'.
0062 
0063   virtual ~G4DataVector() = default;
0064   // Empty destructor
0065 
0066   G4DataVector& operator=(const G4DataVector&) = default;
0067   G4DataVector& operator=(G4DataVector&&) = default;
0068   // Default copy&move assignment operators.
0069 
0070   inline void insertAt(std::size_t, const G4double&);
0071   // Insert an element at given position
0072 
0073   inline std::size_t index(const G4double&) const;
0074   // Returns back index of the element same as given value
0075 
0076   inline G4bool contains(const G4double&) const;
0077   // Returns 'true' if it contains the element same as given value
0078 
0079   inline G4bool remove(const G4double&);
0080   // Removes the first element same as given value
0081 
0082   inline std::size_t removeAll(const G4double&);
0083   // Remove all elements same as given value
0084 
0085   enum
0086   {
0087     T_G4DataVector = 100
0088   };
0089 
0090   G4bool Store(std::ofstream& fOut, G4bool ascii = false);
0091   G4bool Retrieve(std::ifstream& fIn, G4bool ascii = false);
0092   // To store/retrieve persistent data to/from file streams.
0093 
0094   friend std::ostream& operator<<(std::ostream&, const G4DataVector&);
0095 };
0096 
0097 #include "G4DataVector.icc"
0098 
0099 #endif