Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:37

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<T>(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   virtual ~EZMgrFL<T>() {}
0026 
0027   iterator reserve() { return assign(); }
0028   iterator resize() { return assign(); }
0029 
0030   iterator assign(const T& t = T()) {
0031     assert((m_vec.size() + m_subSize) <= m_vecSize);
0032     if (0 == m_vec.capacity()) {
0033       m_vec.reserve(m_vecSize);
0034       assert(m_vecSize == m_vec.capacity());
0035     }
0036     for (size_type i(0); i != m_subSize; ++i) {
0037       m_vec.emplace_back(t);
0038     }
0039     return (m_vec.end() - m_subSize);
0040   }
0041 
0042   size_type subSize() const { return m_subSize; }
0043   size_type size() const { return m_vec.size(); }
0044 
0045   size_type vecSize() const { return m_vec.size(); }
0046 
0047   EZMgrFL() = delete;
0048   EZMgrFL(const EZMgrFL&) = delete;
0049   EZMgrFL& operator=(const EZMgrFL&) = delete;
0050 
0051 private:
0052   const size_type m_vecSize;
0053   const size_type m_subSize;
0054   VecType m_vec;
0055 };
0056 
0057 #endif