Import Geant4 10.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2017-12-08 12:52:30 +01:00
parent 98e455a940
commit fc6af9e721
2166 changed files with 276760 additions and 100873 deletions
+68 -2
View File
@@ -13,7 +13,7 @@ namespace tools {
//////////////////////////////////////////////////////////
template <class T>
inline void clear(std::vector<T*>& a_vec){
inline void safe_clear(std::vector<T*>& a_vec){
// the below takes into account the case in
// which "delete entry" could modify a_vec.
typedef typename std::vector<T*>::iterator it_t;
@@ -25,6 +25,24 @@ inline void clear(std::vector<T*>& a_vec){
}
}
template <class T>
inline void safe_reverse_clear(std::vector<T*>& a_vec){ //used in sg/group.
// the below takes into account the case in
// which "delete entry" could modify a_vec.
typedef typename std::vector<T*>::iterator it_t;
while(!a_vec.empty()) {
it_t it = a_vec.end();
it--;
T* entry = *it;
a_vec.erase(it);
delete entry;
}
}
#ifdef TOOLS_DEPRECATED
template <class T> inline void clear(std::vector<T*>& a_vec){safe_clear<T>(a_vec);}
#endif
template <class T>
inline void raw_clear(std::vector<T*>& a_vec){
typedef typename std::vector<T*>::iterator it_t;
@@ -41,6 +59,9 @@ inline void copy(std::vector<T*>& a_to,const std::vector<T*>& a_from){
}
}
template <class T>
inline void vcopy(std::vector<T*>& a_to,const std::vector<T*>& a_from) {return copy<T>(a_to,a_from);}
template <class T>
inline void append(std::vector<T>& a_vec,const std::vector<T>& a_from) {
typedef typename std::vector<T>::size_type sz_t;
@@ -65,7 +86,7 @@ inline void append(std::vector<T>& a_vec,unsigned int a_num,const T* a_from) {
}
template <class T>
inline void removep(std::vector<T*>& a_vec,T* a_elem) {
inline void removep(std::vector<T*>& a_vec,const T* a_elem) {
typedef typename std::vector<T*>::iterator it_t;
it_t it;
for(it=a_vec.begin();it!=a_vec.end();) {
@@ -110,6 +131,16 @@ inline bool remove(std::vector<T>& a_vals,const T& a_elem){
return found_some;
}
template <class T>
inline void vfilter(std::vector<T>& a_vals,bool(*a_filter_func)(const T& a_elem)){
std::vector<T> vs;
typedef typename std::vector<T>::iterator it_t;
for(it_t it=a_vals.begin();it!=a_vals.end();++it) {
if(a_filter_func(*it)) vs.push_back(*it);
}
a_vals = vs;
}
template <class T>
inline void unique(std::vector<T>& a_vec) {
typedef typename std::vector<T>::iterator it_t;
@@ -206,6 +237,28 @@ inline bool add(std::vector<T>& a_vec,const std::vector<T>& a_v){
return true;
}
template <class T>
inline bool vequ(const std::vector<T>& a_vec,const std::vector<T>& a_v){
if(a_vec.size()!=a_v.size()) return false;
typedef typename std::vector<T>::const_iterator it_t;
typedef typename std::vector<T>::const_iterator cit_t;
it_t it = a_vec.begin();
cit_t vit = a_v.begin();
//size_t count = 0;
for(;it!=a_vec.end();++it,++vit
// ,count++
) {
if((*it)!=(*vit))
//{::printf("debug : %lu : %d %d\n",count,(*it),(*vit));
return false;
//}
}
return true;
}
template <class T>
inline bool vadd(std::vector<T>& a_vec,const std::vector<T>& a_v) {return add<T>(a_vec,a_v);}
template <class T>
inline bool sub(std::vector<T>& a_vec,const std::vector<T>& a_v){
if(a_vec.size()!=a_v.size()) return false;
@@ -252,6 +305,8 @@ inline void mul(std::vector<T>& a_vec,const T& a_v){
typedef typename std::vector<T>::iterator it_t;
for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it *= a_v;
}
template <class T>
inline bool vmul(std::vector<T>& a_vec,const std::vector<T>& a_v) {return vmul<T>(a_vec,a_v);}
template <class T>
inline void div(std::vector<T>& a_vec,const T& a_v){
@@ -259,6 +314,7 @@ inline void div(std::vector<T>& a_vec,const T& a_v){
for(it_t it=a_vec.begin();it!=a_vec.end();++it) *it /= a_v;
}
/*
template <class FROM,class TO>
inline std::vector<TO> convert(const std::vector<FROM>& a_from){
typedef typename std::vector<FROM>::const_iterator const_it_t;
@@ -269,6 +325,16 @@ inline std::vector<TO> convert(const std::vector<FROM>& a_from){
for(;ait!=a_from.end();++ait,++toit) {*toit = (TO)*ait;}
return to;
}
*/
template <class FROM,class TO>
inline void convert(const std::vector<FROM>& a_from,std::vector<TO>& a_to) {
typedef typename std::vector<FROM>::const_iterator const_it_t;
typedef typename std::vector<TO>::iterator it_t;
a_to.resize(a_from.size());
const_it_t ait = a_from.begin();
it_t toit = a_to.begin();
for(;ait!=a_from.end();++ait,++toit) {*toit = (TO)*ait;}
}
template <class T>
inline bool min_max(const std::vector<T>& a_vec,T& a_min,T& a_max) {