Back to home page

EIC code displayed by LXR

 
 

    


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

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 // INCL++ intra-nuclear cascade model
0027 // Alain Boudard, CEA-Saclay, France
0028 // Joseph Cugnon, University of Liege, Belgium
0029 // Jean-Christophe David, CEA-Saclay, France
0030 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
0031 // Sylvie Leray, CEA-Saclay, France
0032 // Davide Mancusi, CEA-Saclay, France
0033 //
0034 #define INCLXX_IN_GEANT4_MODE 1
0035 
0036 #include "globals.hh"
0037 
0038 /*
0039  * \file G4INCLUnorderedVector.hh
0040  *
0041  * \date 2nd October 2014
0042  * \author Davide Mancusi
0043  */
0044 
0045 #ifndef G4INCLUNORDEREDVECTOR_HH_
0046 #define G4INCLUNORDEREDVECTOR_HH_
0047 
0048 #include <vector>
0049 #include <algorithm>
0050 
0051 #if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
0052 // Force instantiation of all the std::vector<Particle*> methods for debugging
0053 // purposes
0054 namespace G4INCL {
0055   class Particle;
0056 }
0057 template class std::vector<G4INCL::Particle*>;
0058 #endif
0059 
0060 namespace G4INCL {
0061 
0062   template<class T>
0063     class UnorderedVector : private std::vector<T> {
0064       public:
0065         UnorderedVector() {}
0066         using std::vector<T>::push_back;
0067         using std::vector<T>::pop_back;
0068         using std::vector<T>::size;
0069         using std::vector<T>::begin;
0070         using std::vector<T>::end;
0071         using std::vector<T>::rbegin;
0072         using std::vector<T>::rend;
0073         using std::vector<T>::front;
0074         using std::vector<T>::back;
0075         using std::vector<T>::clear;
0076         using std::vector<T>::empty;
0077         using std::vector<T>::insert;
0078         using std::vector<T>::erase;
0079         using std::vector<T>::operator[];
0080         using std::vector<T>::reserve;
0081         using std::vector<T>::resize;
0082         using std::vector<T>::at;
0083         using typename std::vector<T>::iterator;
0084         using typename std::vector<T>::reverse_iterator;
0085         using typename std::vector<T>::const_iterator;
0086         using typename std::vector<T>::const_reverse_iterator;
0087 
0088         void remove(const T &t) {
0089           const typename std::vector<T>::iterator removeMe = std::find(begin(), end(), t);
0090 // assert(removeMe!=end());
0091           *removeMe = back();
0092           pop_back();
0093         }
0094 
0095         G4bool contains(const T &t) const {
0096           return (std::find(begin(), end(), t)!=end());
0097         }
0098     };
0099 
0100 }
0101 
0102 #endif // G4INCLUNORDEREDVECTOR_HH_