tudocomp
– The TU Dortmund Compression Framework
FixedVector.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 
5 namespace tdc {namespace esp {
6  template<typename T, size_t N>
7  class FixedVector {
8  std::array<T, N> m_array;
9  size_t m_size = 0;
10  public:
11  inline FixedVector() {}
12  inline void push_back(T&& t) {
13  DCHECK_LT(m_size, N);
14  m_array[m_size] = std::move(t);
15  m_size++;
16  }
17  inline T pop_back() {
18  DCHECK_GT(m_size, 0);
19  m_size--;
20  return std::move(m_array[m_size]);
21  }
22  inline T pop_front() {
23  DCHECK_GT(m_size, 0);
24  auto e = std::move(m_array[0]);
25 
26  for(size_t i = 0; i < m_size - 1; i++) {
27  m_array[i] = m_array[i + 1];
28  }
29  m_size--;
30 
31  return std::move(e);
32  }
33  inline bool full() {
34  return m_size == N;
35  }
36  inline GenericView<T> view() {
37  return GenericView<T> { m_array.data(), m_size };
38  }
39  };
40 }}
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
A view into a slice of memory.
const value_type * data() const noexcept
The backing memory location.
GenericView< T > view()
Definition: FixedVector.hpp:36