CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Geometry/CaloGeometry/interface/EZMgrFL.h

Go to the documentation of this file.
00001 #ifndef GEOMETRY_CALOGEOMETRY_EZMGRFL_H
00002 #define GEOMETRY_CALOGEOMETRY_EZMGRFL_H 1
00003 
00004 #include <vector>
00005 #include <assert.h>
00006 
00007 template < class T >
00008 class EZMgrFL
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       EZMgrFL< T >( size_type vecSize ,
00021                     size_type subSize   ) : m_vecSize ( vecSize ) ,
00022                                             m_subSize ( subSize )
00023       {
00024          m_vec.resize(0); 
00025          assert( subSize > 0 ) ;
00026          assert( vecSize > 0 ) ;
00027          assert( 0 == m_vec.capacity() ) ;
00028       }
00029 
00030       virtual ~EZMgrFL< T >() {}
00031 
00032       iterator reserve() const { return assign() ; }
00033       iterator resize()  const { return assign() ; }
00034 
00035       iterator assign( const T& t = T() ) const
00036       {
00037          assert( ( m_vec.size() + m_subSize ) <= m_vecSize ) ;
00038          if( 0 == m_vec.capacity() )
00039          {
00040             m_vec.reserve( m_vecSize ) ;
00041             assert( m_vecSize == m_vec.capacity() ) ;
00042          }
00043          for( size_type  i ( 0 ) ; i != m_subSize ; ++i )
00044          {
00045             m_vec.push_back( t ) ;
00046          }
00047          return ( m_vec.end() - m_subSize ) ;
00048       }
00049 
00050       size_type subSize() const { return m_subSize ; }
00051       size_type size() const { return m_vec.size(); }
00052 
00053       size_type vecSize() const { return m_vec.size() ; }
00054 
00055    private:
00056 
00057       EZMgrFL() ; //stop
00058       EZMgrFL( const EZMgrFL& ) ; //stop
00059       EZMgrFL& operator=( const EZMgrFL& ) ; //stop
00060 
00061       const size_type m_vecSize ;
00062       const size_type m_subSize ;
00063       mutable VecType m_vec     ;
00064 };
00065 
00066 #endif