Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:16

0001 #ifndef GEOMETRY_CALOGEOMETRY_EZMGRFL_H
0002 #define GEOMETRY_CALOGEOMETRY_EZMGRFL_H 1
0003 
0004 #include <vector>
0005 #include <cassert>
0006 
0007 template <class T>
0008 class EZMgrFL {
0009 public:
0010   typedef std::vector<T> VecType;
0011   typedef typename VecType::iterator iterator;
0012   typedef typename VecType::const_iterator const_iterator;
0013   typedef typename VecType::reference reference;
0014   typedef typename VecType::const_reference const_reference;
0015   typedef typename VecType::value_type value_type;
0016   typedef typename VecType::size_type size_type;
0017 
0018   EZMgrFL(size_type vecSize, size_type subSize) : m_vecSize(vecSize), m_subSize(subSize) {
0019     m_vec.resize(0);
0020     assert(subSize > 0);
0021     assert(vecSize > 0);
0022     assert(0 == m_vec.capacity());
0023   }
0024 
0025   iterator reserve() { return assign(); }
0026   iterator resize() { return assign(); }
0027 
0028   iterator assign(const T& t = T()) {
0029     assert((m_vec.size() + m_subSize) <= m_vecSize);
0030     if (0 == m_vec.capacity()) {
0031       m_vec.reserve(m_vecSize);
0032       assert(m_vecSize == m_vec.capacity());
0033     }
0034     for (size_type i(0); i != m_subSize; ++i) {
0035       m_vec.emplace_back(t);
0036     }
0037     return (m_vec.end() - m_subSize);
0038   }
0039 
0040   size_type subSize() const { return m_subSize; }
0041   size_type size() const { return m_vec.size(); }
0042 
0043   size_type vecSize() const { return m_vec.size(); }
0044 
0045   EZMgrFL() = delete;
0046   EZMgrFL(const EZMgrFL&) = delete;
0047   EZMgrFL& operator=(const EZMgrFL&) = delete;
0048 
0049 private:
0050   const size_type m_vecSize;
0051   const size_type m_subSize;
0052   VecType m_vec;
0053 };
0054 
0055 #endif