tudocomp
– The TU Dortmund Compression Framework
ArrayDS.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <tudocomp/util.hpp>
5 
6 namespace tdc {
7 
9 class ArrayDS: public DynamicIntVector {
10 public:
13 
14 protected:
17  bool m_is_initialized = false;
18  )
19 
20  inline void debug_check_array_is_initialized() const {
21  IF_DEBUG(
22  DCHECK(m_is_initialized);
23  )
24  }
25 
26  inline void set_array(iv_t&& iv) {
27  (iv_t&)(*this) = std::move(iv);
28  IF_DEBUG(m_is_initialized = true;)
29  }
30 public:
31  inline ArrayDS() {}
32  inline ArrayDS(const ArrayDS& other) = delete;
33  inline ArrayDS(ArrayDS&& other): DynamicIntVector(std::move(other)){
34  IF_DEBUG(m_is_initialized = other.m_is_initialized;)
35  }
36  inline ArrayDS& operator=(ArrayDS&& other) {
37  set_array(std::move(other));
38  IF_DEBUG(m_is_initialized = other.m_is_initialized;)
39  return *this;
40  }
41 
43  using data_type = iv_t;
44 
50  inline iv_t relinquish() {
51  debug_check_array_is_initialized();
52  IF_DEBUG(m_is_initialized = false;)
53  return std::move(static_cast<iv_t&>(*this));
54  }
55 
57  inline iv_t copy() const {
58  debug_check_array_is_initialized();
59  return iv_t(*this);
60  }
61 
62 };
63 
64 } //ns
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
iv_t relinquish()
Forces the data structure to relinquish its data storage.
Definition: ArrayDS.hpp:50
DynamicIntVector iv_t
The type of integer array to use as storage.
Definition: ArrayDS.hpp:12
iv_t copy() const
Creates a copy of the data structure&#39;s storage.
Definition: ArrayDS.hpp:57
A vector over arbitrary unsigned integer types.
Definition: IntVector.hpp:175
ArrayDS & operator=(ArrayDS &&other)
Definition: ArrayDS.hpp:36
Base for data structures that use an integer array as a storage.
Definition: ArrayDS.hpp:9
ArrayDS(ArrayDS &&other)
Definition: ArrayDS.hpp:33
IF_DEBUG(bool m_is_initialized=false;) inline void debug_check_array_is_initialized() const
Definition: ArrayDS.hpp:15
void set_array(iv_t &&iv)
Definition: ArrayDS.hpp:26
IntVector< dynamic_t > DynamicIntVector
Represents an integer vector with unspecified (dynamic) bit width.
Definition: IntVector.hpp:553