CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/Geometry/CaloGeometry/interface/EZArrayVL.h

Go to the documentation of this file.
00001 #ifndef GEOMETRY_CALOGEOMETRY_EZArrayVL_H
00002 #define GEOMETRY_CALOGEOMETRY_EZArrayVL_H 1
00003 
00004 #include "Geometry/CaloGeometry/interface/EZMgrVL.h"
00005 
00006 template < class T >
00007 class EZArrayVL
00008 {
00009    public:
00010 
00011       typedef          EZMgrVL< T >             MgrType ;
00012       typedef typename MgrType::iterator        iterator ;
00013       typedef typename MgrType::const_iterator  const_iterator ;
00014       typedef typename MgrType::reference       reference ;
00015       typedef typename MgrType::const_reference const_reference ;
00016       typedef typename MgrType::size_type       size_type ;
00017       typedef typename MgrType::value_type      value_type ;
00018 
00019       EZArrayVL< T >( const MgrType* mgr       , 
00020                       size_type      size = 0  ,
00021                       const T&       t    = T()  ) :
00022          m_begin ( 0 ) ,
00023          m_size  ( size ) ,
00024          m_mgr   ( mgr )   {}
00025 
00026       EZArrayVL< T >( const MgrType* mgr   , 
00027                       const_iterator start ,
00028                       const_iterator finis       ) :
00029          m_begin ( 0==finis-start ? (iterator)0 : mgr->assign( finis - start ) ) ,
00030          m_size  ( finis - start ) ,
00031          m_mgr   ( mgr )
00032       {
00033          assert( ( finis - start ) > 0 ) ;
00034          iterator i ( begin() ) ;
00035          for( const_iterator ic ( start ) ; ic != finis ; ++ic )
00036          {
00037             (*i) = (*ic) ;
00038          }
00039       }
00040 
00041       virtual ~EZArrayVL< T >() {}
00042 
00043       virtual void resize( size_type size ) { m_mgr->assign( size ) ; }
00044 
00045       virtual void assign( size_type size,
00046                            const T&  t = T() ) const 
00047       {
00048          assert( (iterator)0 == m_begin ) ;
00049          m_size = size ;
00050          m_begin = m_mgr->assign( size, t ) ;
00051       }
00052 
00053       const_iterator begin() const { return m_begin ; } 
00054       const_iterator end()   const { return m_size + m_begin ; }
00055 
00056       reference operator[]( const unsigned int i ) 
00057       {
00058          if( (iterator)0 == m_begin ) assign( m_size ) ;
00059          return *( m_begin + i ) ; 
00060       }
00061 
00062       const_reference operator[]( const unsigned int i ) const 
00063       {
00064          return *( m_begin + i ) ;
00065       }
00066 
00067       bool uninitialized() const { return ( 0 == m_begin ) ;  }
00068 
00069       bool empty()         const { return ( 0 == size() ) ;  }
00070 
00071       size_type size()     const { return ( m_end - m_begin ) ; }
00072 
00073       size_type capacity() const { return size() ; }
00074 
00075    protected:
00076 
00077    private:
00078 
00079       EZArrayVL< T >() ; //stop
00080       //EZArrayVL( const EZArrayVL& ) ; //stop
00081       //EZArrayVL& operator=( const EZArrayVL& ) ; //stop
00082       mutable iterator m_begin   ;
00083       size_type        m_size    ;
00084       const MgrType*   m_mgr   ;
00085 };
00086 
00087 #endif