CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Geometry/CaloGeometry/interface/EZMgrVL.h

Go to the documentation of this file.
00001 #ifndef GEOMETRY_CALOGEOMETRY_EZMGRVL_H
00002 #define GEOMETRY_CALOGEOMETRY_EZMGRVL_H 1
00003 
00004 #include <vector>
00005 #include <assert.h>
00006 
00007 template < class T >
00008 class EZMgrVL
00009 {
00010    public:
00011 
00012       typedef std::vector<T>                    VecType ;
00013       typedef typename VecType::iterator        iterator ;
00014       typedef typename VecType::const_iterator  const_iterator ;
00015       typedef typename VecType::reference       reference ;
00016       typedef typename VecType::const_reference const_reference ;
00017       typedef typename VecType::value_type      value_type ;
00018       typedef typename VecType::size_type       size_type ;
00019 
00020       EZMgrVL< T >( size_type vecSize ) : m_vecSize ( vecSize )
00021       {
00022          m_vec.resize(0); 
00023          assert( m_vec.capacity() == 0 ) ;
00024       }
00025 
00026       virtual ~EZMgrVL< T >() {} 
00027 
00028       iterator reserve( size_type size ) const { return assign( size ) ; }
00029       iterator resize(  size_type size ) const { return assign( size ) ; }
00030 
00031       iterator assign( size_type size, const T& t = T() ) const
00032       {
00033          assert( ( m_vec.size() + size ) <= m_vecSize ) ;
00034          if( 0 == m_vec.capacity() )
00035          {
00036             m_vec.reserve( m_vecSize ) ;
00037             assert( m_vecSize == m_vec.capacity() ) ;
00038          }
00039          for( size_type  i ( 0 ) ; i != size ; ++i )
00040          {
00041             m_vec.push_back( t ) ;
00042          }
00043          return ( m_vec.end() - size )  ;
00044       }
00045 
00046    private:
00047 
00048       EZMgrVL() ; //stop
00049       EZMgrVL( const EZMgrVL& ) ; //stop
00050       EZMgrVL& operator=( const EZMgrVL& ) ; //stop
00051 
00052       const size_type m_vecSize ;
00053       mutable VecType m_vec     ;
00054 };
00055 
00056 #endif