CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EZArrayFL.h
Go to the documentation of this file.
1 #ifndef GEOMETRY_CALOGEOMETRY_EZArrayFL_H
2 #define GEOMETRY_CALOGEOMETRY_EZArrayFL_H 1
3 
5 
6 /*
7 
8  stl-vector-LIKE Class designed to allow many small fixed-length
9  containers to have a common memory managed by a single higher-level object.
10 
11  It has the usual common iterators (begin, end) and functions (size, capacity, etc)
12  but is NOT actually an STL-vector.
13 
14  It practices 'on-demand', or 'lazy evaluation', only allocating
15  memory when requested.
16 
17 */
18 
19 
20 template < class T >
21 class EZArrayFL
22 {
23  public:
24 
26  typedef typename MgrType::iterator iterator ;
28  typedef typename MgrType::reference reference ;
30  typedef typename MgrType::size_type size_type ;
31  typedef typename MgrType::value_type value_type ;
32 
33  EZArrayFL< T >( const MgrType* mgr ) : m_begin ( 0 ) ,
34  m_mgr ( mgr ) {}
35 
36  EZArrayFL< T >( const MgrType* mgr ,
37  const_iterator start ,
38  const_iterator finis ) :
39  m_begin ( 0==finis-start ? (iterator)0 : mgr->assign() ) ,
40  m_mgr ( mgr )
41  {
42  assert( ( finis - start ) == m_mgr->subSize() ) ;
43  iterator i ( begin() ) ;
44  for( const_iterator ic ( start ) ; ic != finis ; ++ic )
45  {
46  (*i) = (*ic) ;
47  }
48  }
49 
50  virtual ~EZArrayFL< T >() {}
51 
52  void resize() const { assign() ; }
53 
54  void assign( const T& t = T() ) const
55  {
56  assert( (iterator)0 == m_begin ) ;
57  m_begin = m_mgr->assign( t ) ;
58  }
59 
60  const_iterator begin() const { return m_begin ; }
61  const_iterator end() const { return m_begin + m_mgr->subSize() ; }
62 
63  reference operator[]( const unsigned int i )
64  {
65  if( (iterator)0 == m_begin ) assign() ;
66  return *( m_begin + i ) ;
67  }
68 
69  const_reference operator[]( const unsigned int i ) const
70  {
71  return *( m_begin + i ) ;
72  }
73 
74  bool uninitialized() const { return ( (iterator)0 == m_begin ) ; }
75 
76  bool empty() const { return ( 0 == size() ) ; }
77 
78  size_type size() const { return m_mgr->subSize() ; }
79 
80  size_type capacity() const { return size() ; }
81 
82  protected:
83 
84  private:
85 
86  EZArrayFL< T >() ; //stop
87  //EZArrayFL( const EZArrayFL& ) ; //stop
88  //EZArrayFL& operator=( const EZArrayFL& ) ; //stop
89  mutable iterator m_begin ;
90  const MgrType* m_mgr ;
91 };
92 
93 #endif
VecType::const_reference const_reference
Definition: EZMgrFL.h:16
int i
Definition: DBlmapReader.cc:9
void resize() const
Definition: EZArrayFL.h:52
VecType::size_type size_type
Definition: EZMgrFL.h:18
const MgrType * m_mgr
Definition: EZArrayFL.h:90
MgrType::size_type size_type
Definition: EZArrayFL.h:30
const_iterator begin() const
Definition: EZArrayFL.h:60
const_reference operator[](const unsigned int i) const
Definition: EZArrayFL.h:69
VecType::value_type value_type
Definition: EZMgrFL.h:17
EZMgrFL< T > MgrType
Definition: EZArrayFL.h:25
MgrType::const_reference const_reference
Definition: EZArrayFL.h:29
MgrType::iterator iterator
Definition: EZArrayFL.h:26
void assign(const T &t=T()) const
Definition: EZArrayFL.h:54
MgrType::reference reference
Definition: EZArrayFL.h:28
size_type size() const
Definition: EZArrayFL.h:78
bool empty() const
Definition: EZArrayFL.h:76
iterator assign(const T &t=T()) const
Definition: EZMgrFL.h:35
VecType::iterator iterator
Definition: EZMgrFL.h:13
size_type subSize() const
Definition: EZMgrFL.h:50
Definition: EZMgrFL.h:8
MgrType::const_iterator const_iterator
Definition: EZArrayFL.h:27
const_iterator end() const
Definition: EZArrayFL.h:61
bool uninitialized() const
Definition: EZArrayFL.h:74
iterator m_begin
Definition: EZArrayFL.h:89
MgrType::value_type value_type
Definition: EZArrayFL.h:31
VecType::reference reference
Definition: EZMgrFL.h:15
size_type capacity() const
Definition: EZArrayFL.h:80
VecType::const_iterator const_iterator
Definition: EZMgrFL.h:14
long double T
reference operator[](const unsigned int i)
Definition: EZArrayFL.h:63