| 4 | |
| 5 | template <class T> |
| 6 | class SparseArray |
| 7 | { |
| 8 | public: |
| 9 | using value_type = T; |
| 10 | using reference = T&; |
| 11 | using const_reference = T const&; |
| 12 | using iterator = ContiguousIterator<T>; |
| 13 | using const_iterator = ContiguousConstIterator<T>; |
| 14 | using difference_type = int32_t; |
| 15 | using size_type = uint32_t; |
| 16 | |
| 17 | inline constexpr SparseArray() noexcept {} |
| 18 | |
| 19 | SparseArray(SparseArray const& a) |
| 20 | : mask_(a.mask_), |
| 21 | values_(a.values_) |
| 22 | {} |
| 23 | |
| 24 | SparseArray(SparseArray&& a) noexcept |
| 25 | { |
| 26 | if (this != &a) { |
| 27 | mask_ = std::move(a.mask_); |
| 28 | values_ = std::move(a.values_); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | SparseArray& operator =(SparseArray const& a) |
| 33 | { |
| 34 | mask_ = a.mask_; |
| 35 | values_ = a.values_; |
| 36 | return *this; |
| 37 | } |
| 38 | |
| 39 | SparseArray& operator =(SparseArray&& a) noexcept |
| 40 | { |
| 41 | if (this != &a) { |
| 42 | mask_ = std::move(a.mask_); |
| 43 | values_ = std::move(a.values_); |
| 44 | } |
| 45 | return *this; |
| 46 | } |
| 47 | |
| 48 | inline constexpr bool empty() const noexcept |
| 49 | { |
| 50 | return values_.empty(); |
| 51 | } |
| 52 | |
| 53 | inline constexpr size_type size() const noexcept |
| 54 | { |
| 55 | return values_.size(); |
| 56 | } |
| 57 | |
| 58 | inline constexpr size_type capacity() const noexcept |
| 59 | { |
| 60 | return values_.capacity(); |
| 61 | } |
| 62 | |
| 63 | inline T const& operator [] (size_type index) const |