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 multi_type_vector(mtv::detail::clone_construction_type,
const multi_type_vector& other);
162 typedef detail::iterator_base<iterator_trait, itr_forward_update> iterator;
163 typedef detail::iterator_base<reverse_iterator_trait, itr_no_update> reverse_iterator;
165 typedef detail::const_iterator_base<const_iterator_trait, itr_forward_update, iterator> const_iterator;
166 typedef detail::const_iterator_base<const_reverse_iterator_trait, itr_no_update, reverse_iterator>
167 const_reverse_iterator;
186 typedef std::pair<iterator, size_type> position_type;
187 typedef std::pair<const_iterator, size_type> const_position_type;
239 static size_type
logical_position(
const const_position_type& pos)
noexcept(std::is_fundamental_v<size_type>);
249 template<
typename Blk>
250 static typename Blk::value_type
get(
const const_position_type& pos);
255 const_iterator begin()
const;
256 const_iterator end()
const;
258 const_iterator cbegin()
const;
259 const_iterator cend()
const;
261 reverse_iterator rbegin();
262 reverse_iterator rend();
264 const_reverse_iterator rbegin()
const;
265 const_reverse_iterator rend()
const;
267 const_reverse_iterator crbegin()
const;
268 const_reverse_iterator crend()
const;
301 multi_type_vector(size_type init_size);
313 multi_type_vector(size_type init_size, const T& value);
329 multi_type_vector(size_type init_size, const T& it_begin, const T& it_end);
336 multi_type_vector(const multi_type_vector& other);
343 multi_type_vector(multi_type_vector&& other) noexcept(nothrow_move_constructible_v);
348 ~multi_type_vector();
382 iterator
set(size_type pos, const T& value);
417 iterator
set(const iterator& pos_hint, size_type pos, const T& value);
441 iterator
set(size_type pos, const T& it_begin, const T& it_end);
481 iterator
set(const iterator& pos_hint, size_type pos, const T& it_begin, const T& it_end);
528 template<typename T, typename... Args>
553 iterator
insert(size_type pos, const T& it_begin, const T& it_end);
593 iterator
insert(const iterator& pos_hint, size_type pos, const T& it_begin, const T& it_end);
606 void get(size_type pos, T& value) const;
620 T
get(size_type pos) const;
678 iterator
release(const iterator& pos_hint, size_type pos, T& value);
731 iterator
release_range(const iterator& pos_hint, size_type start_pos, size_type end_pos);
770 position_type
position(const iterator& pos_hint, size_type pos);
803 const_position_type
position(const const_iterator& pos_hint, size_type pos) const;
829 iterator
transfer(size_type start_pos, size_type end_pos, multi_type_vector& dest, size_type dest_pos);
859 const iterator& pos_hint, size_type start_pos, size_type end_pos, multi_type_vector& dest, size_type dest_pos);
896 iterator
set_empty(size_type start_pos, size_type end_pos);
927 iterator
set_empty(const iterator& pos_hint, size_type start_pos, size_type end_pos);
944 void erase(size_type start_pos, size_type end_pos);
1000 iterator
insert_empty(const iterator& pos_hint, size_type pos, size_type length);
1013 size_type
size() const noexcept(std::is_nothrow_copy_constructible_v<size_type>);
1055 void swap(multi_type_vector& other) noexcept(nothrow_swappable_v);
1065 void swap(size_type start_pos, size_type end_pos, multi_type_vector& other, size_type other_pos);
1072 bool operator==(const multi_type_vector& other) const;
1073 bool operator!=(const multi_type_vector& other) const;
1075 multi_type_vector& operator=(const multi_type_vector& other);
1076 multi_type_vector& operator=(multi_type_vector&& other) noexcept(nothrow_move_assignable_v);
1085 template<typename T>
1088#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
1089 void dump_blocks(std::ostream& os)
const;
1091 void check_block_integrity()
const;
1101 void delete_element_block(block& blk);
1110 void delete_element_blocks(
typename blocks_type::iterator it,
typename blocks_type::iterator it_end);
1112 template<
typename T>
1113 iterator set_impl(size_type pos, size_type block_index,
const T& value);
1115 template<
typename T>
1116 iterator release_impl(size_type pos, size_type block_index, T& value);
1118 template<
typename T>
1119 iterator push_back_impl(T&& value);
1121 template<
typename T,
typename... Args>
1122 iterator emplace_back_impl(Args&&... args);
1133 size_type get_block_position(size_type row, size_type start_block_index = 0)
const;
1139 size_type get_block_position(
const typename value_type::private_data& pos_data, size_type row)
const;
1141 void resize_impl(size_type new_size);
1143 template<
typename T>
1146 template<
typename T,
typename... Args>
1147 void create_new_block_with_emplace_back(
base_element_block*& data,
const T& t, Args&&... args);
1149 template<
typename T>
1150 iterator set_cell_to_middle_of_block(size_type block_index, size_type pos_in_block,
const T& cell);
1152 template<
typename T>
1153 void append_cell_to_block(size_type block_index,
const T& cell);
1155 template<
typename T>
1156 iterator set_cell_to_empty_block(size_type block_index, size_type pos_in_block,
const T& cell);
1158 template<
typename T>
1159 iterator set_cell_to_block_of_size_one(size_type block_index,
const T& cell);
1161 template<
typename T>
1162 void set_cell_to_top_of_data_block(size_type block_index,
const T& cell);
1164 template<
typename T>
1165 void set_cell_to_bottom_of_data_block(size_type block_index,
const T& cell);
1167 iterator transfer_impl(
1168 size_type start_pos, size_type end_pos, size_type block_index1, multi_type_vector& dest, size_type dest_pos);
1173 iterator transfer_single_block(
1174 size_type start_pos, size_type end_pos, size_type block_index1, multi_type_vector& dest, size_type dest_pos);
1180 iterator transfer_multi_blocks(
1181 size_type start_pos, size_type end_pos, size_type block_index1, size_type block_index2, multi_type_vector& dest,
1182 size_type dest_pos);
1192 iterator set_empty_impl(size_type start_pos, size_type end_pos, size_type block_index1,
bool overwrite);
1195 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index1,
1196 size_type block_index2, size_type dblock_index1, size_type dblock_index2);
1198 void swap_single_block(
1199 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index,
1200 size_type other_block_index);
1202 void swap_single_to_multi_blocks(
1203 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index,
1204 size_type dst_block_index1, size_type dst_block_index2);
1206 void swap_multi_to_multi_blocks(
1207 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos, size_type block_index1,
1208 size_type block_index2, size_type dblock_index1, size_type dblock_index2);
1210 void insert_blocks_at(size_type
position, size_type insert_pos, blocks_type& new_blocks);
1212 void prepare_blocks_to_transfer(
1213 blocks_to_transfer& bucket, size_type block_index1, size_type offset1, size_type block_index2,
1216 iterator set_whole_block_empty(size_type block_index,
bool overwrite);
1218 iterator set_empty_in_single_block(size_type start_row, size_type end_row, size_type block_index,
bool overwrite);
1229 iterator set_empty_in_multi_blocks(
1230 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
bool overwrite);
1232 void erase_impl(size_type start_pos, size_type end_pos);
1233 void erase_in_single_block(size_type start_pos, size_type end_pos, size_type block_pos);
1240 iterator insert_empty_impl(size_type pos, size_type block_index, size_type length);
1242 template<
typename T>
1243 iterator set_cells_impl(
1244 size_type row, size_type end_row, size_type block_index1,
const T& it_begin,
const T& it_end);
1246 template<
typename T>
1247 iterator insert_cells_impl(size_type row, size_type block_index,
const T& it_begin,
const T& it_end);
1249 template<
typename T>
1250 iterator set_cells_to_single_block(
1251 size_type start_row, size_type end_row, size_type block_index,
const T& it_begin,
const T& it_end);
1253 template<
typename T>
1254 iterator set_cells_to_multi_blocks(
1255 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
const T& it_begin,
1258 template<
typename T>
1259 iterator set_cells_to_multi_blocks_block1_non_equal(
1260 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
const T& it_begin,
1263 template<
typename T>
1264 iterator set_cells_to_multi_blocks_block1_non_empty(
1265 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
const T& it_begin,
1276 size_type merge_with_adjacent_blocks(size_type block_index);
1285 bool merge_with_next_block(size_type block_index);
1287 template<
typename T>
1288 bool append_to_prev_block(
1289 size_type block_index, element_t cat, size_type length,
const T& it_begin,
const T& it_end);
1291 template<
typename T>
1292 void insert_cells_to_middle(size_type row, size_type block_index,
const T& it_begin,
const T& it_end);
1307 block& set_new_block_to_middle(size_type block_index, size_type offset, size_type new_block_size,
bool overwrite);
1309 block* get_previous_block_of_type(size_type block_index, element_t cat);
1318 block* get_next_block_of_type(size_type block_index, element_t cat);
1338 const base_element_block& src_data, size_type src_offset, size_type dst_index, size_type dst_offset,
1341 void exchange_elements(
1342 const base_element_block& src_data, size_type src_offset, size_type dst_index1, size_type dst_offset1,
1343 size_type dst_index2, size_type dst_offset2, size_type len, blocks_type& new_blocks);
1345 bool append_empty(size_type len);
1347 inline iterator get_iterator(size_type block_index)
1349 typename blocks_type::iterator block_pos = m_blocks.begin();
1350 std::advance(block_pos, block_index);
1351 return iterator(block_pos, m_blocks.end(),
this, block_index);
1354 inline const_iterator get_const_iterator(size_type block_index)
const
1356 typename blocks_type::const_iterator block_pos = m_blocks.begin();
1357 std::advance(block_pos, block_index);
1358 return const_iterator(block_pos, m_blocks.end(),
this, block_index);
1361#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
1362 void debug_check_full(std::string_view location);
1366 using adjust_block_positions_func = detail::adjust_block_positions<blocks_type, Traits::loop_unrolling>;
1369 blocks_type m_blocks;
1370 size_type m_cur_size;