29 #ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_UTIL_HPP
30 #define INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_UTIL_HPP
32 #include "./types.hpp"
87 namespace detail {
namespace mtv {
89 inline void throw_block_position_not_found(
90 const char* method_sig,
int line,
size_t pos,
size_t block_size,
size_t container_size)
92 std::ostringstream os;
93 os << method_sig <<
"#" << line <<
": block position not found! (logical pos="
94 << pos <<
", block size=" << block_size <<
", logical size=" << container_size <<
")";
95 throw std::out_of_range(os.str());
116 template<
typename _T,
typename _SizeT>
117 std::pair<_SizeT, bool> calc_input_end_position(
118 const _T& it_begin,
const _T& it_end, _SizeT pos, _SizeT total_size)
120 using ret_type = std::pair<_SizeT, bool>;
122 _SizeT length = std::distance(it_begin, it_end);
125 return ret_type(0,
false);
127 _SizeT end_pos = pos + length - 1;
128 if (end_pos >= total_size)
129 throw std::out_of_range(
"Input data sequence is too long.");
131 return ret_type(end_pos,
true);
135 T advance_position(
const T& pos,
int steps)
143 if (ret.second + steps < ret.first->size)
151 steps -=
static_cast<int>(ret.first->size - ret.second);
161 if (
static_cast<int>(ret.second) >= -steps)
168 steps +=
static_cast<int>(ret.second + 1);
170 ret.second = ret.first->size - 1;
178 template<
typename _Blk>
181 return _Blk::at(data, offset);
184 #ifndef MDDS_MULTI_TYPE_VECTOR_USE_DEQUE
189 auto it = mdds::mtv::boolean_element_block::cbegin(data);
190 std::advance(it, offset);
Definition: types.hpp:113
static constexpr lu_factor_t loop_unrolling
Definition: util.hpp:82
void element_block_acquired(const base_element_block *block)
Definition: util.hpp:54
void element_block_released(const base_element_block *block)
Definition: util.hpp:64