| 20 | */ |
| 21 | template<typename _Scalar,typename _StorageIndex> |
| 22 | class CompressedStorage |
| 23 | { |
| 24 | public: |
| 25 | |
| 26 | typedef _Scalar Scalar; |
| 27 | typedef _StorageIndex StorageIndex; |
| 28 | |
| 29 | protected: |
| 30 | |
| 31 | typedef typename NumTraits<Scalar>::Real RealScalar; |
| 32 | |
| 33 | public: |
| 34 | |
| 35 | CompressedStorage() |
| 36 | : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) |
| 37 | {} |
| 38 | |
| 39 | explicit CompressedStorage(Index size) |
| 40 | : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) |
| 41 | { |
| 42 | resize(size); |
| 43 | } |
| 44 | |
| 45 | CompressedStorage(const CompressedStorage& other) |
| 46 | : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) |
| 47 | { |
| 48 | *this = other; |
| 49 | } |
| 50 | |
| 51 | CompressedStorage& operator=(const CompressedStorage& other) |
| 52 | { |
| 53 | resize(other.size()); |
| 54 | if(other.size()>0) |
| 55 | { |
| 56 | internal::smart_copy(other.m_values, other.m_values + m_size, m_values); |
| 57 | internal::smart_copy(other.m_indices, other.m_indices + m_size, m_indices); |
| 58 | } |
| 59 | return *this; |
| 60 | } |
| 61 | |
| 62 | void swap(CompressedStorage& other) |
| 63 | { |
| 64 | std::swap(m_values, other.m_values); |
| 65 | std::swap(m_indices, other.m_indices); |
| 66 | std::swap(m_size, other.m_size); |
| 67 | std::swap(m_allocatedSize, other.m_allocatedSize); |
| 68 | } |
| 69 | |
| 70 | ~CompressedStorage() |
| 71 | { |
| 72 | delete[] m_values; |
| 73 | delete[] m_indices; |
| 74 | } |
| 75 | |
| 76 | void reserve(Index size) |
| 77 | { |
| 78 | Index newAllocatedSize = m_size + size; |
| 79 | if (newAllocatedSize > m_allocatedSize) |
nothing calls this directly
no test coverage detected