29 #ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_CUSTOM_FUNC2_HPP
30 #define INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_CUSTOM_FUNC2_HPP
35 namespace mdds {
namespace mtv {
40 template<
typename _Block1,
typename _Block2>
47 case _Block1::block_type:
48 return _Block1::create_block(init_size);
49 case _Block2::block_type:
50 return _Block2::create_block(init_size);
55 return element_block_func::create_new_block(type, init_size);
60 switch (get_block_type(block))
62 case _Block1::block_type:
63 return _Block1::clone_block(block);
64 case _Block2::block_type:
65 return _Block2::clone_block(block);
70 return element_block_func::clone_block(block);
78 switch (get_block_type(*p))
80 case _Block1::block_type:
81 _Block1::delete_block(p);
83 case _Block2::block_type:
84 _Block2::delete_block(p);
87 element_block_func::delete_block(p);
93 switch (get_block_type(block))
95 case _Block1::block_type:
96 _Block1::resize_block(block, new_size);
98 case _Block2::block_type:
99 _Block2::resize_block(block, new_size);
102 element_block_func::resize_block(block, new_size);
108 switch (get_block_type(block))
110 case _Block1::block_type:
111 _Block1::print_block(block);
113 case _Block2::block_type:
114 _Block2::print_block(block);
117 element_block_func::print_block(block);
123 switch (get_block_type(block))
125 case _Block1::block_type:
126 _Block1::erase_block(block, pos);
128 case _Block2::block_type:
129 _Block2::erase_block(block, pos);
132 element_block_func::erase(block, pos);
138 switch (get_block_type(block))
140 case _Block1::block_type:
141 _Block1::erase_block(block, pos, size);
143 case _Block2::block_type:
144 _Block2::erase_block(block, pos, size);
147 element_block_func_base::erase(block, pos, size);
153 switch (get_block_type(dest))
155 case _Block1::block_type:
156 _Block1::append_values_from_block(dest, src);
158 case _Block2::block_type:
159 _Block2::append_values_from_block(dest, src);
162 element_block_func_base::append_values_from_block(dest, src);
166 static void append_values_from_block(
169 switch (get_block_type(dest))
171 case _Block1::block_type:
172 _Block1::append_values_from_block(dest, src, begin_pos, len);
174 case _Block2::block_type:
175 _Block2::append_values_from_block(dest, src, begin_pos, len);
178 element_block_func_base::append_values_from_block(dest, src, begin_pos, len);
182 static void assign_values_from_block(
185 switch (get_block_type(dest))
187 case _Block1::block_type:
188 _Block1::assign_values_from_block(dest, src, begin_pos, len);
190 case _Block2::block_type:
191 _Block2::assign_values_from_block(dest, src, begin_pos, len);
194 element_block_func_base::assign_values_from_block(dest, src, begin_pos, len);
198 static void prepend_values_from_block(
201 switch (get_block_type(dest))
203 case _Block1::block_type:
204 _Block1::prepend_values_from_block(dest, src, begin_pos, len);
206 case _Block2::block_type:
207 _Block2::prepend_values_from_block(dest, src, begin_pos, len);
210 element_block_func_base::prepend_values_from_block(dest, src, begin_pos, len);
214 static void swap_values(
217 switch (get_block_type(blk1))
219 case _Block1::block_type:
220 _Block1::swap_values(blk1, blk2, pos1, pos2, len);
222 case _Block2::block_type:
223 _Block2::swap_values(blk1, blk2, pos1, pos2, len);
226 element_block_func_base::swap_values(blk1, blk2, pos1, pos2, len);
230 static bool equal_block(
233 if (get_block_type(left) == _Block1::block_type)
235 if (get_block_type(right) != _Block1::block_type)
238 return _Block1::get(left) == _Block1::get(right);
240 else if (mtv::get_block_type(right) == _Block1::block_type)
243 if (get_block_type(left) == _Block2::block_type)
245 if (get_block_type(right) != _Block2::block_type)
248 return _Block2::get(left) == _Block2::get(right);
250 else if (mtv::get_block_type(right) == _Block2::block_type)
253 return element_block_func::equal_block(left, right);
258 switch (get_block_type(block))
260 case _Block1::block_type:
261 _Block1::overwrite_values(block, pos, len);
263 case _Block2::block_type:
264 _Block2::overwrite_values(block, pos, len);
273 switch (get_block_type(block))
275 case _Block1::block_type:
276 _Block1::shrink_to_fit(block);
278 case _Block2::block_type:
279 _Block2::shrink_to_fit(block);
282 element_block_func::shrink_to_fit(block);
288 switch (get_block_type(block))
290 case _Block1::block_type:
291 return _Block1::size(block);
292 case _Block2::block_type:
293 return _Block2::size(block);
295 return element_block_func::size(block);
Definition: types.hpp:113
Definition: custom_func2.hpp:42
static void overwrite_values(base_element_block &block, size_t pos, size_t len)
Definition: trait.hpp:660