/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcRecoUtil/MdcRecoUtil-00-01-08/MdcRecoUtil/BesCollectionUtils.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //
00004 // Description:
00005 //      
00006 //      
00007 //
00008 // Environment:
00009 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00010 //
00011 // Author List:
00012 //       Matthias Steinke
00013 //       
00014 //
00015 // Copyright Information:
00016 //
00017 //------------------------------------------------------------------------
00018 
00019 #ifndef BBRCOLLECTIONUTILS_HH
00020 #define BBRCOLLECTIONUTILS_HH
00021 
00022 #include <algorithm>
00023 
00024 //CHANGE namespace babar {
00025 namespace bes {
00026   namespace Collection {
00027 
00028 #ifdef OO_DDL_TRANSLATION
00029     struct PtrLess;
00030 #else
00031     struct PtrLess {
00032       template<class PtrType>
00033       bool operator()(PtrType ptr1, PtrType ptr2) const {
00034         return (*ptr1) < (*ptr2);
00035       }
00036     };   
00037 #endif
00038 
00039     struct DeleteObject{
00040       
00041       // Sun does not like typename, have to use class
00042       // template< typename T >
00043       template< class T >
00044       void operator()(const T* ptr) const {
00045         delete ptr;
00046       }
00047     };
00048     
00049     struct DeleteArray{
00050       
00051       // Sun does not like typename, have to use class
00052       // template< typename T >
00053       template< class T >
00054       void operator()(const T array[]) const {
00055         delete[] array;
00056       }
00057     };
00058     
00073     template < class C, class T >
00074     typename C::difference_type
00075     findIndex( const C& container, const T& value ) { 
00076       typename C::const_iterator found 
00077         = std::find( container.begin(), container.end(), value );
00078 
00079       // Were std::distance available, one would write:               FIXME
00081 
00082       // Meanwhile, this should only compile for iterators for which it is efficient:
00083       return found - container.begin();
00084     }
00085     
00086   }
00087 }
00088 
00089 #endif

Generated on Tue Nov 29 23:13:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7