29 #ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_AOS_MAIN_HPP
30 #define INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_AOS_MAIN_HPP
32 #include "../../global.hpp"
33 #include "../types.hpp"
34 #include "../util.hpp"
35 #include "./iterator.hpp"
36 #include "./block_util.hpp"
38 namespace mdds {
namespace mtv {
namespace aos {
67 template<
typename ElemBlockFunc,
typename Trait = mdds::mtv::default_trait>
71 typedef size_t size_type;
74 typedef mdds::mtv::element_t element_category_type;
75 typedef ElemBlockFunc element_block_func;
105 block(size_type _position, size_type _size);
107 block(
const block& other) =
default;
108 block(block&& other) =
default;
110 void swap(block& other);
111 void clone_to(block& other)
const;
113 block& operator=(
const block&) =
default;
116 struct element_block_deleter
118 void operator() (
const element_block_type* p)
120 element_block_func::delete_block(p);
124 typedef std::vector<block> blocks_type;
126 struct blocks_to_transfer
129 size_type insert_index;
131 blocks_to_transfer();
134 struct iterator_trait
137 typedef blocks_type blocks;
138 typedef typename blocks_type::iterator base_iterator;
141 struct reverse_iterator_trait
144 typedef blocks_type blocks;
145 typedef typename blocks_type::reverse_iterator base_iterator;
148 struct const_iterator_trait
151 typedef blocks_type blocks;
152 typedef typename blocks_type::const_iterator base_iterator;
155 struct const_reverse_iterator_trait
158 typedef blocks_type blocks;
159 typedef typename blocks_type::const_reverse_iterator base_iterator;
168 typedef detail::iterator_base<iterator_trait, itr_forward_update> iterator;
169 typedef detail::iterator_base<reverse_iterator_trait, itr_no_update> reverse_iterator;
171 typedef detail::const_iterator_base<const_iterator_trait, itr_forward_update, iterator> const_iterator;
172 typedef detail::const_iterator_base<const_reverse_iterator_trait, itr_no_update, reverse_iterator> const_reverse_iterator;
191 typedef std::pair<iterator, size_type> position_type;
192 typedef std::pair<const_iterator, size_type> const_position_type;
254 template<
typename Blk>
255 static typename Blk::value_type
get(
const const_position_type& pos);
562 void get(size_type pos, T& value)
const;
576 T
get(size_type pos)
const;
899 void erase(size_type start_pos, size_type end_pos);
1039 template<
typename T>
1042 #ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
1043 void dump_blocks(std::ostream& os)
const;
1045 void check_block_integrity()
const;
1056 void delete_element_block(block& blk);
1065 void delete_element_blocks(
typename blocks_type::iterator it,
typename blocks_type::iterator it_end);
1067 template<
typename T>
1068 iterator set_impl(size_type pos, size_type block_index,
const T& value);
1070 template<
typename T>
1071 iterator release_impl(size_type pos, size_type block_index, T& value);
1073 template<
typename T>
1074 iterator push_back_impl(
const T& value);
1085 size_type get_block_position(size_type row, size_type start_block_index=0)
const;
1091 size_type get_block_position(
const const_iterator& pos_hint, size_type row)
const;
1093 void resize_impl(size_type new_size);
1095 template<
typename T>
1098 template<
typename T>
1099 iterator set_cell_to_middle_of_block(
1100 size_type block_index, size_type pos_in_block,
const T& cell);
1102 template<
typename T>
1103 void append_cell_to_block(size_type block_index,
const T& cell);
1105 template<
typename T>
1106 iterator set_cell_to_empty_block(size_type block_index, size_type pos_in_block,
const T& cell);
1108 template<
typename T>
1109 iterator set_cell_to_block_of_size_one(
1110 size_type block_index,
const T& cell);
1112 template<
typename T>
1113 void set_cell_to_top_of_data_block(
1114 size_type block_index,
const T& cell);
1116 template<
typename T>
1117 void set_cell_to_bottom_of_data_block(
1118 size_type block_index,
const T& cell);
1121 size_type start_pos, size_type end_pos, size_type block_index1,
1128 size_type start_pos, size_type end_pos, size_type block_index1,
1136 size_type start_pos, size_type end_pos, size_type block_index1, size_type block_index2,
1148 size_type start_pos, size_type end_pos, size_type block_index1,
bool overwrite);
1151 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos,
1152 size_type block_index1, size_type block_index2, size_type dblock_index1, size_type dblock_index2);
1154 void swap_single_block(
1155 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos,
1156 size_type block_index, size_type other_block_index);
1158 void swap_single_to_multi_blocks(
1159 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos,
1160 size_type block_index, size_type dst_block_index1, size_type dst_block_index2);
1162 void swap_multi_to_multi_blocks(
1163 multi_type_vector& other, size_type start_pos, size_type end_pos, size_type other_pos,
1164 size_type block_index1, size_type block_index2, size_type dblock_index1, size_type dblock_index2);
1166 void insert_blocks_at(size_type
position, size_type insert_pos, blocks_type& new_blocks);
1168 void prepare_blocks_to_transfer(blocks_to_transfer& bucket, size_type block_index1, size_type offset1, size_type block_index2, size_type offset2);
1170 iterator set_whole_block_empty(size_type block_index,
bool overwrite);
1172 iterator set_empty_in_single_block(
1173 size_type start_row, size_type end_row, size_type block_index,
bool overwrite);
1184 iterator set_empty_in_multi_blocks(
1185 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
1188 void erase_impl(size_type start_pos, size_type end_pos);
1189 void erase_in_single_block(size_type start_pos, size_type end_pos, size_type block_pos);
1196 iterator insert_empty_impl(size_type pos, size_type block_index, size_type length);
1198 template<
typename T>
1200 size_type row, size_type end_row, size_type block_index1,
const T& it_begin,
const T& it_end);
1202 template<
typename T>
1203 iterator insert_cells_impl(size_type row, size_type block_index,
const T& it_begin,
const T& it_end);
1205 template<
typename T>
1206 iterator set_cells_to_single_block(
1207 size_type start_row, size_type end_row, size_type block_index,
1208 const T& it_begin,
const T& it_end);
1210 template<
typename T>
1211 iterator set_cells_to_multi_blocks(
1212 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
1213 const T& it_begin,
const T& it_end);
1215 template<
typename T>
1216 iterator set_cells_to_multi_blocks_block1_non_equal(
1217 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
1218 const T& it_begin,
const T& it_end);
1220 template<
typename T>
1221 iterator set_cells_to_multi_blocks_block1_non_empty(
1222 size_type start_row, size_type end_row, size_type block_index1, size_type block_index2,
1223 const T& it_begin,
const T& it_end);
1233 size_type merge_with_adjacent_blocks(size_type block_index);
1242 bool merge_with_next_block(size_type block_index);
1244 template<
typename T>
1245 bool append_to_prev_block(
1246 size_type block_index, element_category_type cat, size_type length,
1247 const T& it_begin,
const T& it_end);
1249 template<
typename T>
1250 void insert_cells_to_middle(
1251 size_type row, size_type block_index,
const T& it_begin,
const T& it_end);
1266 block& set_new_block_to_middle(
1267 size_type block_index, size_type offset, size_type new_block_size,
bool overwrite);
1269 block* get_previous_block_of_type(size_type block_index, element_category_type cat);
1278 block* get_next_block_of_type(size_type block_index, element_category_type cat);
1298 const element_block_type& src_data, size_type src_offset, size_type dst_index, size_type dst_offset, size_type len);
1300 void exchange_elements(
1302 size_type dst_index1, size_type dst_offset1, size_type dst_index2, size_type dst_offset2,
1303 size_type len, blocks_type& new_blocks);
1305 bool append_empty(size_type len);
1307 inline iterator get_iterator(size_type block_index)
1309 typename blocks_type::iterator block_pos = m_blocks.begin();
1310 std::advance(block_pos, block_index);
1311 return iterator(block_pos, m_blocks.end(), block_index);
1314 inline const_iterator get_const_iterator(size_type block_index)
const
1316 typename blocks_type::const_iterator block_pos = m_blocks.begin();
1317 std::advance(block_pos, block_index);
1318 return const_iterator(block_pos, m_blocks.end(), block_index);
1322 using adjust_block_positions_func =
1323 detail::adjust_block_positions<blocks_type, Trait::loop_unrolling>;
1326 blocks_type m_blocks;
1327 size_type m_cur_size;
1332 #include "main_def.inl"
Definition: aos/iterator.hpp:218
Definition: aos/iterator.hpp:151
Definition: aos/main.hpp:69
iterator set(const iterator &pos_hint, size_type pos, const T &it_begin, const T &it_end)
static const_position_type advance_position(const const_position_type &pos, int steps)
const_position_type position(const const_iterator &pos_hint, size_type pos) const
iterator set(size_type pos, const T &value)
itr_node value_type
Definition: aos/main.hpp:189
iterator insert_empty(size_type pos, size_type length)
typename Trait::event_func event_func
Definition: aos/main.hpp:94
void get(size_type pos, T &value) const
position_type position(const iterator &pos_hint, size_type pos)
iterator set_empty(size_type start_pos, size_type end_pos)
multi_type_vector(size_type init_size, const T &value)
mtv::element_t get_type(size_type pos) const
iterator transfer(const iterator &pos_hint, size_type start_pos, size_type end_pos, multi_type_vector &dest, size_type dest_pos)
static Blk::value_type get(const const_position_type &pos)
iterator push_back_empty()
static const_position_type next_position(const const_position_type &pos)
iterator set(size_type pos, const T &it_begin, const T &it_end)
multi_type_vector(const event_func &hdl)
void swap(multi_type_vector &other)
multi_type_vector(event_func &&hdl)
position_type position(size_type pos)
static size_type logical_position(const const_position_type &pos)
iterator push_back(const T &value)
void resize(size_type new_size)
iterator set_empty(const iterator &pos_hint, size_type start_pos, size_type end_pos)
void swap(size_type start_pos, size_type end_pos, multi_type_vector &other, size_type other_pos)
bool is_empty(size_type pos) const
multi_type_vector(size_type init_size)
const_position_type position(size_type pos) const
static mtv::element_t get_element_type(const T &elem)
size_type block_size() const
multi_type_vector(const multi_type_vector &other)
iterator release(const iterator &pos_hint, size_type pos, T &value)
multi_type_vector(size_type init_size, const T &it_begin, const T &it_end)
iterator transfer(size_type start_pos, size_type end_pos, multi_type_vector &dest, size_type dest_pos)
static position_type next_position(const position_type &pos)
iterator insert_empty(const iterator &pos_hint, size_type pos, size_type length)
iterator release(size_type pos, T &value)
T get(size_type pos) const
static position_type advance_position(const position_type &pos, int steps)
iterator set(const iterator &pos_hint, size_type pos, const T &value)
iterator insert(const iterator &pos_hint, size_type pos, const T &it_begin, const T &it_end)
iterator release_range(size_type start_pos, size_type end_pos)
iterator release_range(const iterator &pos_hint, size_type start_pos, size_type end_pos)
void erase(size_type start_pos, size_type end_pos)
iterator insert(size_type pos, const T &it_begin, const T &it_end)
Definition: types.hpp:113
Definition: iterator_node.hpp:101
Definition: iterator_node.hpp:92