CMS 3D CMS Logo

EZMgrFL.h
Go to the documentation of this file.
1 #ifndef GEOMETRY_CALOGEOMETRY_EZMGRFL_H
2 #define GEOMETRY_CALOGEOMETRY_EZMGRFL_H 1
3 
4 #include <vector>
5 #include <cassert>
6 
7 template < class T >
8 class EZMgrFL
9 {
10  public:
11 
12  typedef std::vector<T> VecType ;
13  typedef typename VecType::iterator iterator ;
14  typedef typename VecType::const_iterator const_iterator ;
15  typedef typename VecType::reference reference ;
16  typedef typename VecType::const_reference const_reference ;
17  typedef typename VecType::value_type value_type ;
18  typedef typename VecType::size_type size_type ;
19 
20  EZMgrFL< T >( size_type vecSize ,
21  size_type subSize )
22  : m_vecSize ( vecSize ) ,
23  m_subSize ( subSize )
24  {
25  m_vec.resize(0);
26  assert( subSize > 0 ) ;
27  assert( vecSize > 0 ) ;
28  assert( 0 == m_vec.capacity() ) ;
29  }
30 
31  virtual ~EZMgrFL< T >() {}
32 
33  iterator reserve() { return assign() ; }
34  iterator resize() { return assign() ; }
35 
36  iterator assign( const T& t = T() )
37  {
38  assert( ( m_vec.size() + m_subSize ) <= m_vecSize ) ;
39  if( 0 == m_vec.capacity() )
40  {
41  m_vec.reserve( m_vecSize ) ;
42  assert( m_vecSize == m_vec.capacity() ) ;
43  }
44  for( size_type i ( 0 ) ; i != m_subSize ; ++i )
45  {
46  m_vec.emplace_back( t ) ;
47  }
48  return ( m_vec.end() - m_subSize ) ;
49  }
50 
51  size_type subSize() const { return m_subSize ; }
52  size_type size() const { return m_vec.size(); }
53 
54  size_type vecSize() const { return m_vec.size() ; }
55 
56  EZMgrFL() = delete;
57  EZMgrFL( const EZMgrFL& ) = delete;
58  EZMgrFL& operator=( const EZMgrFL& ) = delete;
59 
60  private:
61 
62  const size_type m_vecSize ;
63  const size_type m_subSize ;
64  VecType m_vec ;
65 };
66 
67 #endif
VecType::const_reference const_reference
Definition: EZMgrFL.h:16
VecType::size_type size_type
Definition: EZMgrFL.h:18
EZMgrFL()=delete
EZMgrFL & operator=(const EZMgrFL &)=delete
VecType::value_type value_type
Definition: EZMgrFL.h:17
uint16_t size_type
size_type vecSize() const
Definition: EZMgrFL.h:54
VecType::iterator iterator
Definition: EZMgrFL.h:13
size_type subSize() const
Definition: EZMgrFL.h:51
Definition: EZMgrFL.h:8
const size_type m_subSize
Definition: EZMgrFL.h:63
std::vector< T > VecType
Definition: EZMgrFL.h:12
iterator assign(const T &t=T())
Definition: EZMgrFL.h:36
const size_type m_vecSize
Definition: EZMgrFL.h:62
VecType m_vec
Definition: EZMgrFL.h:64
VecType::reference reference
Definition: EZMgrFL.h:15
size_type size() const
Definition: EZMgrFL.h:52
iterator reserve()
Definition: EZMgrFL.h:33
VecType::const_iterator const_iterator
Definition: EZMgrFL.h:14
long double T
iterator resize()
Definition: EZMgrFL.h:34