49class multi_type_vector
52 using size_type = std::size_t;
53 using block_funcs =
typename Traits::block_funcs;
81 block()
noexcept(std::is_fundamental_v<size_type>);
82 block(size_type _position, size_type _size)
noexcept(std::is_fundamental_v<size_type>);
84 std::is_fundamental_v<size_type>);
85 block(
const block& other) =
default;
86 block(block&& other) =
default;
89 block& operator=(
const block&) =
default;
90 block& operator=(block&&) =
default;
92 void swap(block& other)
noexcept(std::is_fundamental_v<size_type>);
95 struct element_block_deleter
99 block_funcs::delete_block(p);
103 typedef std::vector<block> blocks_type;
105 struct blocks_to_transfer
108 size_type insert_index;
110 blocks_to_transfer();
113 struct iterator_trait
116 typedef blocks_type blocks;
117 typedef typename blocks_type::iterator base_iterator;
120 struct reverse_iterator_trait
122 typedef multi_type_vector parent;
123 typedef blocks_type blocks;
124 typedef typename blocks_type::reverse_iterator base_iterator;
127 struct const_iterator_trait
129 typedef multi_type_vector parent;
130 typedef blocks_type blocks;
131 typedef typename blocks_type::const_iterator base_iterator;
134 struct const_reverse_iterator_trait
136 typedef multi_type_vector parent;
137 typedef blocks_type blocks;
138 typedef typename blocks_type::const_reverse_iterator base_iterator;
141 typedef mdds::detail::mtv::iterator_value_node<multi_type_vector, size_type> itr_node;
142 typedef mdds::detail::mtv::private_data_forward_update<multi_type_vector, size_type> itr_forward_update;
143 typedef mdds::detail::mtv::private_data_no_update<multi_type_vector, size_type> itr_no_update;
145 static constexpr bool nothrow_default_constructible_v = std::is_nothrow_default_constructible_v<event_func> &&
146 std::is_nothrow_default_constructible_v<blocks_type> &&
147 std::is_nothrow_default_constructible_v<size_type>;
149 static constexpr bool nothrow_move_constructible_v = std::is_nothrow_move_constructible_v<event_func> &&
150 std::is_nothrow_move_constructible_v<blocks_type> &&
151 std::is_nothrow_move_constructible_v<size_type>;
153 static constexpr bool nothrow_swappable_v = std::is_nothrow_swappable_v<event_func> &&
154 std::is_nothrow_swappable_v<size_type> &&
155 std::is_nothrow_swappable_v<blocks_type>;
157 static constexpr bool nothrow_move_assignable_v = nothrow_move_constructible_v && nothrow_swappable_v;
159 template<stateful_clone_value... CVs>
160 multi_type_vector(mtv::detail::clone_construction_type,
const multi_type_vector& other, CVs&... cloners);
163 typedef detail::iterator_base<iterator_trait, itr_forward_update> iterator;
164 typedef detail::iterator_base<reverse_iterator_trait, itr_no_update> reverse_iterator;
166 typedef detail::const_iterator_base<const_iterator_trait, itr_forward_update, iterator> const_iterator;
167 typedef detail::const_iterator_base<const_reverse_iterator_trait, itr_no_update, reverse_iterator>
168 const_reverse_iterator;
187 typedef std::pair<iterator, size_type> position_type;
188 typedef std::pair<const_iterator, size_type> const_position_type;
240 static size_type
logical_position(
const const_position_type& pos)
noexcept(std::is_fundamental_v<size_type>);
250 template<
typename Blk>
251 static typename Blk::value_type
get(
const const_position_type& pos);
256 const_iterator begin()
const;
257 const_iterator end()
const;
259 const_iterator cbegin()
const;
260 const_iterator cend()
const;
262 reverse_iterator rbegin();
263 reverse_iterator rend();
265 const_reverse_iterator rbegin()
const;
266 const_reverse_iterator rend()
const;
268 const_reverse_iterator crbegin()
const;
269 const_reverse_iterator crend()
const;
288 multi_type_vector() noexcept(nothrow_default_constructible_v);
313 multi_type_vector(size_type init_size);
325 multi_type_vector(size_type init_size, const T& value);
341 multi_type_vector(size_type init_size, const T& it_begin, const T& it_end);
348 multi_type_vector(const multi_type_vector& other);
355 multi_type_vector(multi_type_vector&& other) noexcept(nothrow_move_constructible_v);
360 ~multi_type_vector();
412 multi_type_vector
clone(CVs&... cloners) const;
431 iterator
set(size_type pos, const T& value);
494 iterator
set(size_type pos, const T& it_begin, const T& it_end);
585 template<typename T, typename... Args>
610 iterator
insert(size_type pos, const T& it_begin, const T& it_end);
667 void get(size_type pos, T& value) const;
681 T
get(size_type pos) const;
909 iterator
transfer(size_type start_pos, size_type end_pos, multi_type_vector& dest, size_type dest_pos);
944 position_hint pos_hint, size_type start_pos, size_type end_pos, multi_type_vector& dest, size_type dest_pos);
981 iterator
set_empty(size_type start_pos, size_type end_pos);
1031 void erase(size_type start_pos, size_type end_pos);
1104 size_type
size() const noexcept(std::is_nothrow_copy_constructible_v<size_type>);
1146 void swap(multi_type_vector& other) noexcept(nothrow_swappable_v);
1156 void swap(size_type start_pos, size_type end_pos, multi_type_vector& other, size_type other_pos);
1163 bool operator==(const multi_type_vector& other) const;
1165 multi_type_vector& operator=(const multi_type_vector& other);
1166 multi_type_vector& operator=(multi_type_vector&& other) noexcept(nothrow_move_assignable_v);
1175 template<typename T>
1178#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
1179 void dump_blocks(std::ostream& os)
const;
1181 void check_block_integrity()
const;
1191 void delete_element_block(block& blk);
1200 void delete_element_blocks(
typename blocks_type::iterator it,
typename blocks_type::iterator it_end);
1202 template<
typename T>
1203 iterator set_impl(size_type pos, size_type block_index,
const T& value);
1205 template<
typename T>
1206 iterator release_impl(size_type pos, size_type block_index, T& value);
1208 template<
typename T>
1209 iterator push_back_impl(T&& value);
1211 template<
typename T,
typename... Args>
1212 iterator emplace_back_impl(Args&&... args);
1223 size_type get_block_position(size_type row, size_type start_block_index = 0)
const;
1230 size_type get_block_position(
const position_hint& pos_hint, size_type row)
const;
1232 void resize_impl(size_type new_size);
1234 template<
typename T>
1237 template<
typename T,
typename... Args>
1238 void create_new_block_with_emplace_back(
base_element_block*& data,
const T& t, Args&&... args);
1240 template<
typename T>
1241 iterator set_cell_to_middle_of_block(size_type block_index, size_type pos_in_block,
const T& cell);
1243 template<
typename T>
1244 void append_cell_to_block(size_type block_index,
const T& cell);
1246 template<
typename T>
1247 iterator set_cell_to_empty_block(size_type block_index, size_type pos_in_block,
const T& cell);
1249 template<
typename T>
1250 iterator set_cell_to_block_of_size_one(size_type block_index,
const T& cell);
1252 template<
typename T>
1253 void set_cell_to_top_of_data_block(size_type block_index,
const T& cell);
1255 template<
typename T>
1256 void set_cell_to_bottom_of_data_block(size_type block_index,
const T& cell);
1258 iterator transfer_impl(
1259 size_type start_pos, size_type end_pos, size_type block_index1, multi_type_vector& dest, size_type dest_pos);
1264 iterator transfer_single_block(
1265 size_type start_pos, size_type end_pos, size_type block_index1, multi_type_vector& dest, size_type dest_pos);
1271 iterator transfer_multi_blocks(
1272 size_type start_pos, size_type end_pos, size_type block_index1, size_type block_index2, multi_type_vector& dest,
1273 size_type dest_pos);
1283 iterator set_empty_impl(size_type start_pos, size_type end_pos, size_type block_index1,
bool overwrite);
1286 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index1,
1287 size_type block_index2, size_type dblock_index1, size_type dblock_index2);
1289 void swap_single_block(
1290 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index,
1291 size_type other_block_index);
1293 void swap_single_to_multi_blocks(
1294 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index,
1295 size_type dst_block_index1, size_type dst_block_index2);
1297 void swap_multi_to_multi_blocks(
1298 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index1,
1299 size_type block_index2, size_type dblock_index1, size_type dblock_index2);
1301 void insert_blocks_at(size_type
position, size_type insert_pos, blocks_type& new_blocks);
1303 void prepare_blocks_to_transfer(
1304 blocks_to_transfer& bucket, size_type block_index1, size_type offset1, size_type block_index2,
1307 iterator set_whole_block_empty(size_type block_index,
bool overwrite);
1309 iterator set_empty_in_single_block(size_type start_row, size_type end_row, size_type block_index,
bool overwrite);
1320 iterator set_empty_in_multi_blocks(
1321 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
bool overwrite);
1323 void erase_impl(size_type start_pos, size_type end_pos);
1324 void erase_in_single_block(size_type start_pos, size_type end_pos, size_type block_pos);
1331 iterator insert_empty_impl(size_type pos, size_type block_index, size_type length);
1333 template<
typename T>
1334 iterator set_cells_impl(
1335 size_type row, size_type end_row, size_type block_index1,
const T& it_begin,
const T& it_end);
1337 template<
typename T>
1338 iterator insert_cells_impl(size_type row, size_type block_index,
const T& it_begin,
const T& it_end);
1340 template<
typename T>
1341 iterator set_cells_to_single_block(
1342 size_type start_row, size_type end_row, size_type block_index,
const T& it_begin,
const T& it_end);
1344 template<
typename T>
1345 iterator set_cells_to_multi_blocks(
1346 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
const T& it_begin,
1349 template<
typename T>
1350 iterator set_cells_to_multi_blocks_block1_non_equal(
1351 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
const T& it_begin,
1354 template<
typename T>
1355 iterator set_cells_to_multi_blocks_block1_non_empty(
1356 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
const T& it_begin,
1367 size_type merge_with_adjacent_blocks(size_type block_index);
1376 bool merge_with_next_block(size_type block_index);
1378 template<
typename T>
1379 bool append_to_prev_block(
1380 size_type block_index, element_t cat, size_type length,
const T& it_begin,
const T& it_end);
1382 template<
typename T>
1383 void insert_cells_to_middle(size_type row, size_type block_index,
const T& it_begin,
const T& it_end);
1398 block& set_new_block_to_middle(size_type block_index, size_type offset, size_type new_block_size,
bool overwrite);
1400 block* get_previous_block_of_type(size_type block_index, element_t cat);
1409 block* get_next_block_of_type(size_type block_index, element_t cat);
1429 const base_element_block& src_data, size_type src_offset, size_type dst_index, size_type dst_offset,
1432 void exchange_elements(
1433 const base_element_block& src_data, size_type src_offset, size_type dst_index1, size_type dst_offset1,
1434 size_type dst_index2, size_type dst_offset2, size_type len, blocks_type& new_blocks);
1436 bool append_empty(size_type len);
1438 inline iterator get_iterator(size_type block_index)
1440 typename blocks_type::iterator block_pos = m_blocks.begin();
1441 std::advance(block_pos, block_index);
1442 return iterator(block_pos, m_blocks.end(),
this, block_index, m_id);
1445 inline const_iterator get_const_iterator(size_type block_index)
const
1447 typename blocks_type::const_iterator block_pos = m_blocks.begin();
1448 std::advance(block_pos, block_index);
1449 return const_iterator(block_pos, m_blocks.end(),
this, block_index, m_id);
1452#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
1453 void debug_check_full(std::string_view location);
1457 using adjust_block_positions_func = detail::adjust_block_positions<blocks_type, Traits::loop_unrolling>;
1460 blocks_type m_blocks;
1461 size_type m_cur_size;
1463 container_id_t m_id = mtv::detail::next_container_id();