31 template <
typename PosT>
33 {
return pos.descend(
this_t{}, idx); }
35 template <
typename PosT>
37 {
return pos.node()->leaf(); }
44 using result_t = std::tuple<T*, size_t, size_t>;
46 template <
typename PosT>
48 {
return pos.towards(
this_t{}, idx); }
50 template <
typename PosT>
52 {
return { pos.node()->leaf(), pos.index(idx), pos.count() }; }
60 template <
typename PosT>
62 {
return pos.descend(
this_t{}, idx); }
64 template <
typename PosT>
66 {
return pos.node()->leaf() [pos.index(idx)]; }
73 template <
typename Pos,
typename Fn>
75 { pos.each(
this_t{}, fn); }
77 template <
typename Pos,
typename Fn>
80 auto data = pos.node()->leaf();
81 fn(data, data + pos.count());
89 template <
typename Pos,
typename Fn>
91 {
return pos.each_pred(
this_t{}, fn); }
93 template <
typename Pos,
typename Fn>
96 auto data = pos.node()->leaf();
97 return fn(data, data + pos.count());
105 template <
typename Pos,
typename Fn>
107 size_t last, Fn&& fn)
109 auto l = pos.index(last);
111 pos.towards_oh(
this_t{}, last, l, fn);
114 template <
typename Pos,
typename Fn>
119 auto data = pos.node()->leaf();
120 auto l = pos.index(last);
121 fn(data, data + l + 1);
129 template <
typename Pos,
typename Fn>
131 size_t first, Fn&& fn)
133 auto f = pos.index(first);
134 pos.towards_oh(
this_t{}, first, f, fn);
138 template <
typename Pos,
typename Fn>
143 auto data = pos.node()->leaf();
144 auto f = pos.index(first);
145 fn(data + f, data + pos.count());
153 template <
typename Pos,
typename Fn>
155 size_t first,
size_t last,
161 auto f = pos.index(first);
162 auto l = pos.index(last - 1);
164 auto sbh = pos.size_before(f);
165 pos.towards_oh_sbh(
this_t{}, first, f, sbh, last - sbh, fn);
175 template <
typename Pos,
typename Fn>
177 size_t first,
size_t last,
181 auto f = pos.index(first);
182 auto l = pos.index(last - 1);
184 pos.towards_oh(
this_t{}, first, f, last, fn);
194 template <
typename Pos,
typename Fn>
196 size_t first,
size_t last,
199 auto data = pos.node()->leaf();
201 auto f = pos.index(first);
202 auto l = pos.index(last - 1);
203 fn(data + f, data + l + 1);
213 template <
typename Pos,
typename Fn>
215 size_t last, Fn&& fn)
217 auto l = pos.index(last);
219 && pos.towards_oh(
this_t{}, last, l, fn);
222 template <
typename Pos,
typename Fn>
227 auto data = pos.node()->leaf();
228 auto l = pos.index(last);
229 return fn(data, data + l + 1);
238 template <
typename Pos,
typename Fn>
240 size_t first, Fn&& fn)
242 auto f = pos.index(first);
243 return pos.towards_oh(
this_t{}, first, f, fn)
247 template <
typename Pos,
typename Fn>
252 auto data = pos.node()->leaf();
253 auto f = pos.index(first);
254 return fn(data + f, data + pos.count());
262 template <
typename Pos,
typename Fn>
264 size_t first,
size_t last,
270 auto f = pos.index(first);
271 auto l = pos.index(last - 1);
273 auto sbh = pos.size_before(f);
274 return pos.towards_oh_sbh(
this_t{}, first, f, sbh, last - sbh, fn);
285 template <
typename Pos,
typename Fn>
287 size_t first,
size_t last,
291 auto f = pos.index(first);
292 auto l = pos.index(last - 1);
294 return pos.towards_oh(
this_t{}, first, f, last, fn);
305 template <
typename Pos,
typename Fn>
307 size_t first,
size_t last,
310 auto data = pos.node()->leaf();
312 auto f = pos.index(first);
313 auto l = pos.index(last - 1);
314 return fn(data + f, data + l + 1);
326 template <
typename PosR,
typename PosL,
typename Iter>
329 Iter&& first,
size_t idx)
330 {
return posl.nth_sub(i,
this_t{}, posr, first, idx); }
332 template <
typename PosR,
typename PosL,
typename Iter>
335 Iter&& first,
size_t idx)
336 {
return posl.nth_sub_leaf(i,
this_t{}, posr, first, idx); }
341 template <
typename PosR,
typename Iter,
typename Node>
343 Node* rootl,
shift_t shiftl,
size_t sizel)
345 assert(shiftl <= posr.shift());
346 return shiftl == posr.shift()
348 this_t{}, posr, first,
size_t{})
349 : posr.first_sub_inner(
rrb{}, first, rootl, shiftl, sizel);
353 template <
typename Iter>
356 return [iter] (
auto f,
auto e)
mutable {
361 for (; f != e; ++f, ++iter)
368 template <
typename PosL,
typename PosR,
typename Iter>
370 Iter&& first,
size_t idx)
372 auto nl = posl.node();
373 auto nr = posr.node();
376 auto cl = posl.count();
377 auto cr = posr.count();
382 for (; i < cl; ++i) {
383 auto sbl = posl.size_before(i);
384 for (; j + 1 < cr && (sbr = posr.size_before(j)) < sbl; ++j);
385 auto res = sbl == sbr
386 ? posr.nth_sub(j,
this_aux_t{}, i, posl, first, idx + sbl)
389 if (!res)
return false;
394 template <
typename PosL,
typename PosR,
typename Iter>
395 static std::enable_if_t<is_relaxed_v<PosR>,
bool>
401 template <
typename PosL,
typename PosR,
typename Iter>
402 static std::enable_if_t<!is_relaxed_v<PosR>,
bool>
405 return posl.count() >= posr.count()
410 template <
typename PosL,
typename PosR,
typename Iter>
412 PosR&& posr, Iter&& first,
size_t idx)
414 if (posl.node() == posr.node())
416 auto cl = posl.count();
417 auto cr = posr.count();
418 auto mp = std::min(cl, cr);
420 std::equal(posl.node()->leaf(),
421 posl.node()->leaf() + mp,
422 posr.node()->leaf()) &&
423 std::equal(posl.node()->leaf() + mp,
424 posl.node()->leaf() + posl.count(),
428 template <
typename Pos,
typename NodeT>
431 auto node = pos.node();
433 || pos.each_pred_zip(
this_t{}, other);
436 template <
typename Pos,
typename NodeT>
439 auto node = pos.node();
446 template <
typename NodeT>
452 template <
typename Pos,
typename Fn>
455 auto offset = pos.index(idx);
456 auto count = pos.count();
457 auto node = node_t::make_inner_sr_n(
count, pos.relaxed());
459 auto child = pos.towards_oh(
this_t{}, idx, offset, fn);
460 node_t::do_copy_inner_sr(
node, pos.node(),
count);
470 template <
typename Pos,
typename Fn>
473 auto offset = pos.index(idx);
474 auto count = pos.count();
477 auto child = pos.towards_oh_ch(
this_t{}, idx, offset,
count, fn);
478 node_t::do_copy_inner(
node, pos.node(),
count);
488 template <
typename Pos,
typename Fn>
491 auto offset = pos.index(idx);
492 auto node = node_t::copy_leaf(pos.node(), pos.count());
494 node->
leaf()[offset] = std::forward<Fn>(fn) (
498 node_t::delete_leaf(
node, pos.count());
508 template <
typename Pos>
512 auto node = p.node();
515 node_t::delete_inner_r(
node, p.count());
519 template <
typename Pos>
523 auto node = p.node();
526 node_t::delete_inner(
node, p.count());
530 template <
typename Pos>
534 auto node = p.node();
536 node_t::delete_leaf(
node, p.count());
541 template <
typename NodeT>
547 template <
typename NodeT>
553 template <
typename NodeT>
559 template <
typename NodeT>
565 template <
typename NodeT>
571 template <
typename NodeT>
579 template <
typename Pos>
583 auto offset = pos.index(idx);
584 auto count = pos.count();
585 auto node = pos.node();
587 return pos.towards_oh(
this_t{}, idx, offset,
590 auto new_node = node_t::copy_inner_sr_e(e,
node,
count);
592 auto& res = pos.towards_oh(
this_t{}, idx, offset,
593 e, &new_node->inner()[offset]);
595 *location = new_node;
604 template <
typename Pos>
608 assert(pos.node() == *location);
609 auto offset = pos.index(idx);
610 auto count = pos.count();
611 auto node = pos.node();
613 return pos.towards_oh_ch(
this_t{}, idx, offset,
count,
616 auto new_node = node_t::copy_inner_e(e,
node,
count);
618 auto& res = pos.towards_oh_ch(
this_t{}, idx, offset,
count,
619 e, &new_node->inner()[offset]);
621 *location = new_node;
630 template <
typename Pos>
634 assert(pos.node() == *location);
635 auto node = pos.node();
637 return node->
leaf() [pos.index(idx)];
639 auto new_node = node_t::copy_leaf_e(e, pos.node(), pos.count());
641 *location = new_node;
642 return new_node->leaf() [pos.index(idx)];
647 template <
typename NodeT,
bool Mutating = true>
659 template <
typename Pos>
662 auto node = pos.node();
663 auto level = pos.shift();
664 auto idx = pos.count() - 1;
665 auto children = pos.size(idx);
666 auto new_idx = children ==
size_t{1} << level || level ==
BL 668 auto new_child =
static_cast<node_t*
>(
nullptr);
671 if (new_idx >= branches<B>)
673 else if (idx == new_idx) {
675 ? pos.last_oh_csh(
this_t{}, idx, children, e, tail, ts)
676 : pos.last_oh_csh(
this_no_mut_t{}, idx, children, e, tail, ts);
678 if (++new_idx < branches<B>)
679 new_child = node_t::make_path_e(e, level -
B, tail);
684 new_child = node_t::make_path_e(e, level -
B, tail);
687 auto count = new_idx + 1;
690 relaxed->d.sizes[new_idx] = pos.size() + ts;
691 relaxed->d.count =
count;
695 auto count = new_idx + 1;
696 auto new_node = node_t::copy_inner_r_e(e, pos.node(), new_idx);
697 auto relaxed = new_node->relaxed();
698 new_node->inner()[new_idx] = new_child;
699 relaxed->d.sizes[new_idx] = pos.size() + ts;
700 relaxed->d.count =
count;
704 auto shift = pos.shift();
705 auto size = new_idx == idx ? children + ts : ts;
715 template <
typename Pos,
typename... Args>
718 assert((pos.size() & mask<BL>) == 0);
719 auto node = pos.node();
720 auto idx = pos.index(pos.size() - 1);
721 auto new_idx = pos.index(pos.size() + branches<BL> - 1);
725 idx == new_idx ? pos.last_oh(
this_t{}, idx, e, tail)
726 : node_t::make_path_e(e, pos.shift() -
B, tail);
729 auto new_parent = node_t::make_inner_e(e);
731 new_parent->inner()[new_idx] =
733 : node_t::make_path_e(e, pos.shift() -
B, tail);
734 node_t::do_copy_inner(new_parent,
node, new_idx);
738 node_t::delete_inner_e(new_parent);
744 template <
typename Pos,
typename... Args>
749 template <
typename NodeT>
758 template <
typename Pos>
761 auto level = pos.shift();
762 auto idx = pos.count() - 1;
763 auto children = pos.size(idx);
764 auto new_idx = children ==
size_t{1} << level || level ==
BL 766 auto new_child =
static_cast<node_t*
>(
nullptr);
767 if (new_idx >= branches<B>)
769 else if (idx == new_idx) {
770 new_child = pos.last_oh_csh(
this_t{}, idx, children, tail, ts);
772 if (++new_idx < branches<B>)
773 new_child = node_t::make_path(level -
B, tail);
778 new_child = node_t::make_path(level -
B, tail);
780 auto count = new_idx + 1;
781 auto new_parent = node_t::copy_inner_r_n(
count, pos.node(), new_idx);
782 auto new_relaxed = new_parent->relaxed();
783 new_parent->inner()[new_idx] = new_child;
784 new_relaxed->d.sizes[new_idx] = pos.size() + ts;
785 new_relaxed->d.count =
count;
788 auto shift = pos.shift();
789 auto size = new_idx == idx ? children + ts : ts;
798 template <
typename Pos,
typename... Args>
801 assert((pos.size() & mask<BL>) == 0);
802 auto idx = pos.index(pos.size() - 1);
803 auto new_idx = pos.index(pos.size() + branches<BL> - 1);
804 auto count = new_idx + 1;
805 auto new_parent = node_t::make_inner_n(
count);
807 new_parent->inner()[new_idx] =
808 idx == new_idx ? pos.last_oh(
this_t{}, idx, tail)
809 : node_t::make_path(pos.shift() -
B, tail);
811 node_t::delete_inner(new_parent,
count);
814 return node_t::do_copy_inner(new_parent, pos.node(), new_idx);
817 template <
typename Pos,
typename... Args>
827 template <
typename Pos>
831 auto node = p.node();
833 p.each_right(
dec_t{}, idx);
834 node_t::delete_inner_r(
node, p.count());
838 template <
typename Pos>
842 auto node = p.node();
844 p.each_right(
dec_t{}, idx);
845 node_t::delete_inner(
node, p.count());
849 template <
typename Pos>
854 template <
typename NodeT,
bool Collapse=true,
bool Mutating=true>
856 :
visitor_base<slice_right_mut_visitor<NodeT, Collapse, Mutating>>
863 using result_t = std::tuple<shift_t, NodeT*, count_t, NodeT*>;
871 template <
typename PosT>
874 auto idx = pos.index(last);
875 auto node = pos.node();
877 if (Collapse && idx == 0) {
879 ? pos.towards_oh(
this_t{}, last, idx, e)
880 : pos.towards_oh(
no_mut_t{}, last, idx, e);
888 auto next = get<1>(subs);
889 auto ts = get<2>(subs);
890 auto tail = get<3>(subs);
897 nodr->d.sizes[idx] = last + 1 - ts;
898 nodr->d.count = idx + 1;
899 return { pos.shift(),
node, ts, tail };
901 auto newn = node_t::copy_inner_r_e(e,
node, idx);
902 auto newr = newn->relaxed();
903 newn->inner()[idx] = next;
904 newr->d.sizes[idx] = last + 1 - ts;
905 newr->d.count = idx + 1;
907 return { pos.shift(), newn, ts, tail };
909 }
else if (idx == 0) {
911 return { pos.shift(),
nullptr, ts, tail };
912 }
else if (Collapse && idx == 1 && pos.shift() >
BL) {
913 auto newn = pos.node()->inner()[0];
914 if (!mutate) newn->inc();
916 return { pos.shift() -
B, newn, ts, tail };
921 return { pos.shift(),
node, ts, tail };
923 auto newn = node_t::copy_inner_r_e(e,
node, idx);
925 return { pos.shift(), newn, ts, tail };
930 assert(!next || pos.shift() >
BL);
933 last + 1 - ts - pos.size_before(idx));
940 template <
typename PosT>
943 auto idx = pos.index(last);
944 auto node = pos.node();
946 if (Collapse && idx == 0) {
948 ? pos.towards_oh(
this_t{}, last, idx, e)
949 : pos.towards_oh(
no_mut_t{}, last, idx, e);
957 auto next = get<1>(subs);
958 auto ts = get<2>(subs);
959 auto tail = get<3>(subs);
965 return { pos.shift(),
node, ts, tail };
967 auto newn = node_t::copy_inner_e(e,
node, idx);
968 newn->inner()[idx] = next;
970 return { pos.shift(), newn, ts, tail };
972 }
else if (idx == 0) {
974 return { pos.shift(),
nullptr, ts, tail };
975 }
else if (Collapse && idx == 1 && pos.shift() >
BL) {
976 auto newn = pos.node()->inner()[0];
977 if (!mutate) newn->inc();
979 return { pos.shift() -
B, newn, ts, tail };
983 return { pos.shift(),
node, ts, tail };
985 auto newn = node_t::copy_inner_e(e,
node, idx);
987 return { pos.shift(), newn, ts, tail };
992 assert(!next || pos.shift() >
BL);
994 if (next)
dec_regular(next, pos.shift() -
B, last + 1 - ts);
1001 template <
typename PosT>
1004 auto old_tail_size = pos.count();
1005 auto new_tail_size = pos.index(last) + 1;
1006 auto node = pos.node();
1008 if (new_tail_size == old_tail_size) {
1010 return { 0,
nullptr, new_tail_size,
node };
1011 }
else if (mutate) {
1013 old_tail_size - new_tail_size);
1014 return { 0,
nullptr, new_tail_size,
node };
1016 auto new_tail = node_t::copy_leaf_e(e,
node, new_tail_size);
1018 return { 0,
nullptr, new_tail_size, new_tail };
1023 template <
typename NodeT,
bool Collapse=true>
1030 using result_t = std::tuple<shift_t, NodeT*, count_t, NodeT*>;
1036 template <
typename PosT>
1039 auto idx = pos.index(last);
1040 if (Collapse && idx == 0) {
1041 return pos.towards_oh(
this_t{}, last, idx);
1045 auto next = get<1>(subs);
1046 auto ts = get<2>(subs);
1047 auto tail = get<3>(subs);
1050 auto count = idx + 1;
1051 auto newn = node_t::copy_inner_r_n(
count, pos.node(), idx);
1052 auto newr = newn->relaxed();
1053 newn->inner()[idx] = next;
1054 newr->d.sizes[idx] = last + 1 - ts;
1055 newr->d.count =
count;
1056 return { pos.shift(), newn, ts, tail };
1057 }
else if (idx == 0) {
1058 return { pos.shift(),
nullptr, ts, tail };
1059 }
else if (Collapse && idx == 1 && pos.shift() >
BL) {
1060 auto newn = pos.node()->inner()[0];
1061 return { pos.shift() -
B, newn->inc(), ts, tail };
1063 auto newn = node_t::copy_inner_r(pos.node(), idx);
1064 return { pos.shift(), newn, ts, tail };
1067 assert(!next || pos.shift() >
BL);
1069 last + 1 - ts - pos.size_before(idx));
1076 template <
typename PosT>
1079 auto idx = pos.index(last);
1080 if (Collapse && idx == 0) {
1081 return pos.towards_oh(
this_t{}, last, idx);
1085 auto next = get<1>(subs);
1086 auto ts = get<2>(subs);
1087 auto tail = get<3>(subs);
1090 auto newn = node_t::copy_inner_n(idx + 1, pos.node(), idx);
1091 newn->inner()[idx] = next;
1092 return { pos.shift(), newn, ts, tail };
1093 }
else if (idx == 0) {
1094 return { pos.shift(),
nullptr, ts, tail };
1095 }
else if (Collapse && idx == 1 && pos.shift() >
BL) {
1096 auto newn = pos.node()->inner()[0];
1097 return { pos.shift() -
B, newn->inc(), ts, tail };
1099 auto newn = node_t::copy_inner_n(idx, pos.node(), idx);
1100 return { pos.shift(), newn, ts, tail };
1103 assert(!next || pos.shift() >
BL);
1105 if (next)
dec_regular(next, pos.shift() -
B, last + 1 - ts);
1112 template <
typename PosT>
1115 auto old_tail_size = pos.count();
1116 auto new_tail_size = pos.index(last) + 1;
1117 auto new_tail = new_tail_size == old_tail_size
1119 : node_t::copy_leaf(pos.node(), new_tail_size);
1120 return { 0,
nullptr, new_tail_size, new_tail };
1129 template <
typename Pos>
1133 auto node = p.node();
1135 p.each_left(
dec_t{}, idx);
1136 node_t::delete_inner_r(
node, p.count());
1140 template <
typename Pos>
1144 auto node = p.node();
1146 p.each_left(
dec_t{}, idx);
1147 node_t::delete_inner(
node, p.count());
1151 template <
typename Pos>
1156 template <
typename NodeT,
bool Collapse=true,
bool Mutating=true>
1158 :
visitor_base<slice_left_mut_visitor<NodeT, Collapse, Mutating>>
1175 template <
typename PosT>
1178 auto idx = pos.subindex(first);
1179 auto count = pos.count();
1180 auto node = pos.node();
1182 auto left_size = pos.size_before(idx);
1183 auto child_size = pos.size_sbh(idx, left_size);
1184 auto dropped_size = first;
1185 auto child_dropped_size = dropped_size - left_size;
1186 if (Collapse && pos.shift() >
BL && idx == pos.count() - 1) {
1188 ? pos.towards_sub_oh(
this_t{}, first, idx, e)
1189 : pos.towards_sub_oh(
no_mut_t{}, first, idx, e);
1196 : node_t::make_inner_r_e(e);
1197 auto newr = newn->relaxed();
1198 auto newcount =
count - idx;
1199 auto new_child_size = child_size - child_dropped_size;
1205 pos.copy_sizes(idx + 1, newcount - 1,
1206 new_child_size, newr->d.sizes + 1);
1210 newn->inner()[0] = get<1>(subs);
1211 newr->d.sizes[0] = new_child_size;
1212 newr->d.count = newcount;
1214 node_t::inc_nodes(newn->inner() + 1, newcount - 1);
1217 return { pos.shift(), newn };
1219 if (!mutate) node_t::delete_inner_r_e(newn);
1225 template <
typename PosT>
1228 auto idx = pos.subindex(first);
1229 auto count = pos.count();
1230 auto node = pos.node();
1231 auto mutate = Mutating
1235 && !node_t::embed_relaxed
1237 auto left_size = pos.size_before(idx);
1238 auto child_size = pos.size_sbh(idx, left_size);
1239 auto dropped_size = first;
1240 auto child_dropped_size = dropped_size - left_size;
1241 if (Collapse && pos.shift() >
BL && idx == pos.count() - 1) {
1243 ? pos.towards_sub_oh(
this_t{}, first, idx, e)
1244 : pos.towards_sub_oh(
no_mut_t{}, first, idx, e);
1253 auto newcount =
count - idx;
1255 ? (
node->
impl.d.data.inner.relaxed =
new (
1256 node_t::heap::allocate(
1257 node_t::max_sizeof_relaxed,
1260 : node_t::make_inner_r_e(e);
1261 auto newr = newn->relaxed();
1267 newr->d.sizes[0] = child_size - child_dropped_size;
1268 pos.copy_sizes(idx + 1, newcount - 1,
1269 newr->d.sizes[0], newr->d.sizes + 1);
1270 newr->d.count = newcount;
1271 newn->inner()[0] = get<1>(subs);
1276 node_t::inc_nodes(newn->inner() + 1, newcount - 1);
1279 return { pos.shift(), newn };
1281 if (!mutate) node_t::delete_inner_r_e(newn);
1285 node_t::heap::deallocate(node_t::max_sizeof_relaxed,
1287 node->
impl.d.data.inner.relaxed =
nullptr;
1294 template <
typename PosT>
1297 auto node = pos.node();
1298 auto idx = pos.index(first);
1299 auto count = pos.count();
1300 auto mutate = Mutating
1301 && std::is_nothrow_move_constructible<value_t>::value
1305 auto newcount =
count - idx;
1306 std::move(data + idx, data +
count, data);
1310 auto newn = node_t::copy_leaf_e(e,
node, idx,
count);
1317 template <
typename NodeT,
bool Collapse=true>
1330 template <
typename PosT>
1333 auto idx = pos.subindex(first);
1334 auto count = pos.count();
1335 auto left_size = pos.size_before(idx);
1336 auto child_size = pos.size_sbh(idx, left_size);
1337 auto dropped_size = first;
1338 auto child_dropped_size = dropped_size - left_size;
1339 if (Collapse && pos.shift() >
BL && idx == pos.count() - 1) {
1340 return pos.towards_sub_oh(
this_t{}, first, idx);
1343 auto n = pos.node();
1344 auto newc =
count - idx;
1345 auto newn = node_t::make_inner_r_n(newc);
1347 auto subs = pos.towards_sub_oh(
no_collapse_t{}, first, idx);
1348 auto newr = newn->relaxed();
1349 newr->d.count =
count - idx;
1350 newr->d.sizes[0] = child_size - child_dropped_size;
1351 pos.copy_sizes(idx + 1, newr->d.count - 1,
1352 newr->d.sizes[0], newr->d.sizes + 1);
1353 assert(newr->d.sizes[newr->d.count - 1] == pos.size() - dropped_size);
1354 newn->inner()[0] = get<1>(subs);
1358 node_t::inc_nodes(newn->inner() + 1, newr->d.count - 1);
1359 return { pos.shift(), newn };
1361 node_t::delete_inner_r(newn, newc);
1367 template <
typename PosT>
1370 auto n = node_t::copy_leaf(pos.node(), pos.index(first), pos.count());
1375 template <
typename Node>
1394 Node* n0,
size_t s0)
1398 Node* n0,
size_t s0,
1399 Node* n1,
size_t s1)
1403 Node* n0,
size_t s0,
1404 Node* n1,
size_t s1,
1405 Node* n2,
size_t s2)
1408 template <
typename Visitor,
typename... Args>
1424 auto result = node_t::make_inner_r_n(
count_);
1425 auto r = result->relaxed();
1429 return { result,
shift_, r };
1443 auto result = node_t::make_inner_r_e(e);
1444 auto r = result->relaxed();
1448 return { result,
shift_, r };
1456 template <
typename Node>
1472 ,
result_{shift +
B, node_t::make_inner_r_n(std::min(
n_, branches<B>)), 0}
1483 auto relaxed = parent->relaxed();
1484 if (relaxed->d.count == branches<B>) {
1487 parent = node_t::make_inner_r_n(std::min(
n_, branches<B>));
1488 relaxed = parent->relaxed();
1493 auto idx = relaxed->d.count++;
1495 relaxed->d.sizes[idx] = size + (idx ? relaxed->d.sizes[idx - 1] : 0);
1496 parent->inner() [idx] = p;
1499 template <
typename Pos>
1502 auto from = p.node();
1503 auto from_size = p.size();
1504 auto from_count = p.count();
1506 if (!
to_ && *
curr_ == from_count) {
1511 auto from_data = from->leaf();
1517 auto data =
to_->leaf();
1518 auto to_copy = std::min(from_count - from_offset,
1521 from_data + from_offset + to_copy,
1524 from_offset += to_copy;
1529 }
while (from_offset != from_count);
1533 template <
typename Pos>
1536 auto from = p.node();
1537 auto from_size = p.size();
1538 auto from_count = p.count();
1540 if (!
to_ && *
curr_ == from_count) {
1545 auto from_data = from->inner();
1548 to_ = node_t::make_inner_r_n(*
curr_);
1552 auto data =
to_->inner();
1553 auto to_copy = std::min(from_count - from_offset,
1556 from_data + from_offset + to_copy,
1558 node_t::inc_nodes(from_data + from_offset, to_copy);
1559 auto sizes =
to_->relaxed()->d.sizes;
1560 p.copy_sizes(from_offset, to_copy,
1563 from_offset += to_copy;
1570 }
while (from_offset != from_count);
1599 template <
typename Pos,
typename Merger>
1601 { merger.merge_inner(p); }
1603 template <
typename Pos,
typename Merger>
1605 { merger.merge_leaf(p); }
1613 template <
typename Pos,
typename Plan>
1616 auto count = p.count();
1617 assert(plan.n < Plan::max_children);
1618 plan.counts[plan.n++] =
count;
1619 plan.total +=
count;
1623 template <bits_t B, bits_t BL>
1632 template <
typename LPos,
typename CPos,
typename RPos>
1633 void fill(LPos&& lpos, CPos&& cpos, RPos&& rpos)
1636 assert(
total == 0u);
1638 lpos.each_left_sub(visitor_t{}, *
this);
1639 cpos.each_sub(visitor_t{}, *
this);
1640 rpos.each_right_sub(visitor_t{}, *
this);
1646 #if !defined(_MSC_VER) 1647 #pragma GCC diagnostic push 1648 #pragma GCC diagnostic ignored "-Warray-bounds" 1650 constexpr
count_t rrb_extras = 2;
1651 constexpr
count_t rrb_invariant = 1;
1652 const auto bits = shift == BL ? BL : B;
1654 const auto optimal = ((
total - 1) >>
bits) + 1;
1656 while (
n >= optimal + rrb_extras) {
1660 auto remaining =
counts[i];
1666 }
while (remaining > 0);
1672 #if !defined(_MSC_VER) 1673 #pragma GCC diagnostic pop 1677 template <
typename LPos,
typename CPos,
typename RPos>
1679 merge(LPos&& lpos, CPos&& cpos, RPos&& rpos)
1684 auto merger = merger_t{cpos.shift(),
counts,
n};
1686 lpos.each_left_sub(visitor_t{}, merger);
1687 cpos.each_sub(visitor_t{}, merger);
1688 rpos.each_right_sub(visitor_t{}, merger);
1690 return merger.finish();
1698 template <
typename Node,
typename LPos,
typename CPos,
typename RPos>
1699 concat_center_pos<Node>
1703 plan.
fill(lpos, cpos, rpos);
1704 plan.shuffle(cpos.shift());
1706 return plan.merge(lpos, cpos, rpos);
1713 template <
typename Node,
typename LPos,
typename TPos,
typename RPos>
1714 concat_center_pos<Node>
1718 assert(lpos.shift() == tpos.shift());
1719 assert(lpos.shift() == rpos.shift());
1720 assert(lpos.shift() == 0);
1721 if (tpos.count() > 0)
1724 lpos.node()->inc(), lpos.count(),
1725 tpos.node()->inc(), tpos.count(),
1726 rpos.node()->inc(), rpos.count(),
1731 lpos.node()->inc(), lpos.count(),
1732 rpos.node()->inc(), rpos.count(),
1736 template <
typename Node>
1738 template <
typename Node>
1740 template <
typename Node>
1743 template <
typename Node,
typename LPos,
typename TPos,
typename RPos>
1747 auto lshift = lpos.shift();
1748 auto rshift = rpos.shift();
1749 if (lshift > rshift) {
1751 return concat_rebalance<Node>(lpos, cpos,
null_sub_pos{});
1752 }
else if (lshift < rshift) {
1754 return concat_rebalance<Node>(
null_sub_pos{}, cpos, rpos);
1756 assert(lshift == rshift);
1759 return concat_rebalance<Node>(lpos, cpos, rpos);
1763 template <
typename Node>
1764 struct concat_left_visitor : visitor_base<concat_left_visitor<Node>>
1768 template <
typename LPos,
typename TPos,
typename RPos>
1771 {
return concat_inners<Node>(lpos, tpos, rpos); }
1773 template <
typename LPos,
typename TPos,
typename RPos>
1779 template <
typename Node>
1780 struct concat_right_visitor : visitor_base<concat_right_visitor<Node>>
1784 template <
typename RPos,
typename LPos,
typename TPos>
1787 {
return concat_inners<Node>(lpos, tpos, rpos); }
1789 template <
typename RPos,
typename LPos,
typename TPos>
1792 {
return concat_leafs<Node>(lpos, tpos, rpos); }
1795 template <
typename Node>
1796 struct concat_both_visitor
1797 : visitor_base<concat_both_visitor<Node>>
1801 template <
typename LPos,
typename TPos,
typename RPos>
1806 template <
typename LPos,
typename TPos,
typename RPos>
1812 template <
typename Node>
1818 template <
typename RPos,
typename LPos,
typename TPos>
1821 {
return concat_inners<Node>(lpos, tpos, rpos); }
1824 template <
typename Node>
1830 template <
typename LPos,
typename TPos,
typename... Args>
1839 template <
typename Node>
1843 Node* rroot,
shift_t rshift,
size_t rsize)
1846 lroot, lshift, lsize,
1849 rroot, rshift, rsize)
1853 template <
typename Node>
1856 Node* rroot,
shift_t rshift,
size_t rsize)
1861 rroot, rshift, rsize)
1865 template <
typename Node>
1868 template <
typename Node>
1897 candidate->ensure_mutable_relaxed_e(candidate_e, ec);
1915 auto relaxed = parent->relaxed();
1916 if (
count_ == branches<B>) {
1917 parent->relaxed()->d.count =
count_;
1925 parent = node_t::make_inner_r_e(
ec_);
1927 relaxed = parent->relaxed();
1934 relaxed->d.sizes[idx] = size + (idx ? relaxed->d.sizes[idx - 1] : 0);
1935 parent->inner() [idx] = p;
1938 template <
typename Pos>
1941 auto from = p.node();
1942 auto from_size = p.size();
1943 auto from_count = p.count();
1945 if (!
to_ && *
curr_ == from_count) {
1949 auto from_data = from->leaf();
1950 auto from_mutate = from->can_mutate(e);
1954 node_t::ownee(from) =
ec_;
1958 to_ = node_t::make_leaf_e(
ec_);
1962 auto data =
to_->leaf();
1963 auto to_copy = std::min(from_count - from_offset,
1967 std::move(from_data + from_offset,
1968 from_data + from_offset + to_copy,
1973 from_data + from_offset + to_copy,
1977 from_data + from_offset + to_copy,
1981 from_offset += to_copy;
1986 }
while (from_offset != from_count);
1990 template <
typename Pos>
1993 auto from = p.node();
1994 auto from_size = p.size();
1995 auto from_count = p.count();
1997 if (!
to_ && *
curr_ == from_count) {
2001 auto from_data = from->inner();
2002 auto from_mutate = from->can_relax() && from->can_mutate(e);
2006 node_t::ownee(from) =
ec_;
2007 from->ensure_mutable_relaxed_e(e,
ec_);
2010 to_ = node_t::make_inner_r_e(
ec_);
2015 auto data =
to_->inner();
2016 auto to_copy = std::min(from_count - from_offset,
2018 auto sizes =
to_->relaxed()->d.sizes;
2021 from_data + from_offset + to_copy,
2023 p.copy_sizes(from_offset, to_copy,
2027 from_offset += to_copy;
2034 }
while (from_offset != from_count);
2059 template <
typename Pos,
typename Merger>
2062 { merger.merge_inner(p, e); }
2064 template <
typename Pos,
typename Merger>
2067 { merger.merge_leaf(p, e); }
2070 template <bits_t B, bits_t BL>
2075 template <
typename LPos,
typename CPos,
typename RPos>
2084 auto lnode = ((node_t*)lpos.node());
2085 auto rnode = ((node_t*)rpos.node());
2086 auto lmut2 = lnode && lnode->can_relax() && lnode->can_mutate(el);
2087 auto rmut2 = rnode && rnode->can_relax() && rnode->can_mutate(er);
2088 auto merger = merger_t{
2089 ec, cpos.shift(), this->
counts, this->
n,
2090 el, lmut2 ? lnode :
nullptr 2093 lpos.each_left_sub(visitor_t{}, merger, el);
2094 cpos.each_sub(visitor_t{}, merger, ec);
2095 if (rmut2) merger.set_candidate(er, rnode);
2096 rpos.each_right_sub(visitor_t{}, merger, er);
2097 return merger.finish();
2105 template <
typename Node,
typename LPos,
typename CPos,
typename RPos>
2106 concat_center_pos<Node>
2112 plan.
fill(lpos, cpos, rpos);
2113 plan.shuffle(cpos.shift());
2114 return plan.merge(ec, el, lpos, cpos, er, rpos);
2117 template <
typename Node,
typename LPos,
typename TPos,
typename RPos>
2118 concat_center_mut_pos<Node>
2124 assert(lpos.shift() == tpos.shift());
2125 assert(lpos.shift() == rpos.shift());
2126 assert(lpos.shift() == 0);
2127 if (tpos.count() > 0)
2130 lpos.node(), lpos.count(),
2131 tpos.node(), tpos.count(),
2132 rpos.node(), rpos.count(),
2137 lpos.node(), lpos.count(),
2138 rpos.node(), rpos.count(),
2142 template <
typename Node>
2144 template <
typename Node>
2146 template <
typename Node>
2149 template <
typename Node,
typename LPos,
typename TPos,
typename RPos>
2155 auto lshift = lpos.shift();
2156 auto rshift = rpos.shift();
2159 if (lshift > rshift) {
2161 ec, el, tpos, er, rpos);
2162 return concat_rebalance_mut<Node>(ec,
2165 }
else if (lshift < rshift) {
2167 ec, el, lpos, tpos, er);
2168 return concat_rebalance_mut<Node>(ec,
2172 assert(lshift == rshift);
2175 ec, el, tpos, er, rpos);
2176 return concat_rebalance_mut<Node>(ec,
2182 template <
typename Node>
2183 struct concat_left_mut_visitor : visitor_base<concat_left_mut_visitor<Node>>
2188 template <
typename LPos,
typename TPos,
typename RPos>
2193 {
return concat_inners_mut<Node>(
2194 ec, el, lpos, tpos, er, rpos); }
2196 template <
typename LPos,
typename TPos,
typename RPos>
2204 template <
typename Node>
2205 struct concat_right_mut_visitor
2206 : visitor_base<concat_right_mut_visitor<Node>>
2211 template <
typename RPos,
typename LPos,
typename TPos>
2214 edit_t el, LPos&& lpos, TPos&& tpos,
2216 {
return concat_inners_mut<Node>(
2217 ec, el, lpos, tpos, er, rpos); }
2219 template <
typename RPos,
typename LPos,
typename TPos>
2222 edit_t el, LPos&& lpos, TPos&& tpos,
2224 {
return concat_leafs_mut<Node>(
2225 ec, el, lpos, tpos, er, rpos); }
2228 template <
typename Node>
2229 struct concat_both_mut_visitor
2230 : visitor_base<concat_both_mut_visitor<Node>>
2235 template <
typename LPos,
typename TPos,
typename RPos>
2241 ec, el, lpos, tpos, er); }
2243 template <
typename LPos,
typename TPos,
typename RPos>
2249 ec, el, lpos, tpos, er); }
2252 template <
typename Node>
2259 template <
typename RPos,
typename LPos,
typename TPos>
2262 edit_t el, LPos&& lpos, TPos&& tpos,
2264 {
return concat_inners_mut<Node>(
2265 ec, el, lpos, tpos, er, rpos); }
2268 template <
typename Node>
2275 template <
typename LPos,
typename TPos,
typename... Args>
2279 edit_t er, Args&& ...args)
2283 ec, el, lpos, tpos, er); }
2286 template <
typename Node>
2290 Node* lroot,
shift_t lshift,
size_t lsize,
2293 Node* rroot,
shift_t rshift,
size_t rsize)
2296 lroot, lshift, lsize,
2300 er, rroot, rshift, rsize)
2304 template <
typename Node>
2310 Node* rroot,
shift_t rshift,
size_t rsize)
2316 er, rroot, rshift, rsize)
static result_t visit_leaf(PosT &&pos, size_t first, edit_t e)
static void visit_regular(Pos &&pos, size_t first, size_t last, Fn &&fn)
typename NodeT::edit_t edit_t
typename NodeT::edit_t edit_t
static bool visit_leaf(PosL &&posl, PosR &&posr, Iter &&first, size_t idx)
OutIter copy(Range &&r, OutIter out)
static void visit_relaxed(Pos &&p, count_t idx)
static void visit_relaxed(Pos &&p)
static constexpr count_t max_children
void add_child(node_t *p, size_t size)
static void visit_inner(Pos &&pos, Fn &&fn)
typename Node::edit_t edit_t
static result_t visit_relaxed(PosT &&pos, size_t first, edit_t e)
void destroy_n(T *p, Size n)
relaxed_pos< NodeT > make_relaxed_pos(NodeT *node, shift_t shift, typename NodeT::relaxed_t *relaxed)
static bool visit_leaf(PosR &&posr, count_t i, PosL &&posl, Iter &&first, size_t idx)
concat_center_pos(shift_t s, Node *n0, size_t s0, Node *n1, size_t s1)
static bool visit_regular(Pos &&pos, NodeT *other)
static concat_center_pos< Node > visit_leaf(LPos &&lpos, TPos &&tpos, RPos &&rpos)
concat_center_pos< Node > concat_rebalance_mut(edit_type< Node > ec, edit_type< Node > el, LPos &&lpos, CPos &&cpos, edit_type< Node > er, RPos &&rpos)
static void visit_leaf(Pos &&pos, size_t last, Fn &&fn)
static bool visit_inner(Pos &&pos, Fn &&fn)
concat_center_mut_pos< Node > concat_inners_mut(edit_type< Node > ec, edit_type< Node > el, LPos &&lpos, TPos &&tpos, edit_type< Node > er, RPos &&rpos)
static concat_center_mut_pos< Node > visit_inner(LPos &&lpos, edit_t ec, edit_t el, TPos &&tpos, edit_t er, RPos &&rpos)
void shuffle(shift_t shift)
std::tuple< shift_t, NodeT *, count_t, NodeT * > result_t
static bool visit_inner(Pos &&pos, size_t last, Fn &&fn)
static bool visit_leaf(Pos &&pos, size_t last, Fn &&fn)
static node_t * visit_relaxed(Pos &&pos, edit_t e, node_t *tail, count_t ts)
static concat_center_pos< Node > visit_inner(LPos &&lpos, TPos &&tpos, RPos &&rpos)
node_t * nodes_[max_children]
static void visit_leaf(Pos &&p, count_t idx)
static bool visit_leaf(Pos &&pos, size_t first, size_t last, Fn &&fn)
static concat_center_pos< Node > visit_inner(RPos &&rpos, LPos &&lpos, TPos &&tpos)
static node_t * visit_leaf(Pos &&pos, size_t idx, Fn &&fn)
empty_regular_pos< NodeT > make_empty_regular_pos(NodeT *node)
static concat_center_pos< Node > visit_node(RPos &&rpos, LPos &&lpos, TPos &&tpos)
static void visit_inner(Pos &&pos, size_t last, Fn &&fn)
concat_center_pos< Node > concat_leafs(LPos &&lpos, TPos &&tpos, RPos &&rpos)
void fill(LPos &&lpos, CPos &&cpos, RPos &&rpos)
static concat_center_mut_pos< Node > visit_inner(LPos &&lpos, edit_t ec, edit_t el, TPos &&tpos, edit_t er, RPos &&rpos)
relaxed_pos< Node > concat_trees_mut(edit_type< Node > ec, edit_type< Node > el, Node *lroot, shift_t lshift, size_t lsize, Node *ltail, count_t ltcount, edit_type< Node > er, Node *rroot, shift_t rshift, size_t rsize)
concat_center_mut_pos< Node > concat_leafs_mut(edit_type< Node > ec, edit_type< Node > el, LPos &&lpos, TPos &&tpos, edit_type< Node > er, RPos &&rpos)
static value_t & visit_regular(Pos &&pos, size_t idx, edit_t e, node_t **location)
typename std::decay< Pos >::type::node_t node_type
static void visit_regular(Pos &&p)
static bool visit_regular(Pos &&pos, size_t first, size_t last, Fn &&fn)
static result_t visit_leaf(PosT &&pos, size_t idx)
typename Node::edit_t edit_t
std::tuple< shift_t, NodeT * > result_t
SinkIter uninitialized_copy(Iterator first, Sentinel last, SinkIter d_first)
concat_center_pos< Node > concat_rebalance(LPos &&lpos, CPos &&cpos, RPos &&rpos)
leaf_pos< NodeT > make_leaf_pos(NodeT *node, size_t size)
static concat_center_pos< Node > visit_leaf(RPos &&rpos, LPos &&lpos, TPos &&tpos)
static std::enable_if_t<!is_relaxed_v< PosR >, bool > visit_regular(PosL &&posl, PosR &&posr, Iter &&first, size_t idx)
static void visit_inner(Pos &&p, Merger &merger, edit_type< Pos > e)
void dec_empty_regular(NodeT *node)
concat_center_pos< Node > finish() const
static concat_center_mut_pos< Node > visit_leaf(LPos &&lpos, edit_t ec, edit_t el, TPos &&tpos, edit_t er, RPos &&rpos)
static result_t visit_inner(PosT &&pos, size_t first)
static value_t & visit_relaxed(Pos &&pos, size_t idx, edit_t e, node_t **location)
typename Node::edit_t edit_t
static auto equal_chunk_p(Iter &&iter)
static result_t visit_relaxed(PosT &&pos, size_t last)
static void visit_inner(Pos &&pos, size_t first, Fn &&fn)
static bool visit_relaxed(PosL &&posl, PosR &&posr, Iter &&first, size_t idx)
std::tuple< shift_t, NodeT * > result_t
relaxed_pos< Node > realize_e(edit_t e)
static node_t * visit_leaf(Pos &&pos, node_t *tail, Args &&...)
typename NodeT::value_t value_t
static bool visit_node(PosR &&posr, Iter &&first, Node *rootl, shift_t shiftl, size_t sizel)
concat_center_pos< node_type< CPos > > merge(LPos &&lpos, CPos &&cpos, RPos &&rpos)
concat_center_pos< Node > finish() const
static node_t * visit_leaf(Pos &&pos, edit_t e, node_t *tail, Args &&...)
void dec_leaf(NodeT *node, count_t n)
static bool visit_inner(PosR &&posr, count_t i, PosL &&posl, Iter &&first, size_t idx)
typename Node::edit_t edit_t
concat_merger(shift_t shift, count_t *counts, count_t n)
static void visit_leaf(Pos &&pos, size_t first, Fn &&fn)
void dec_relaxed(NodeT *node, shift_t shift)
static result_t visit_regular(PosT &&pos, size_t last)
regular_pos< NodeT > make_regular_pos(NodeT *node, shift_t shift, size_t size)
concat_center_pos(shift_t s, Node *n0, size_t s0)
std::tuple< shift_t, NodeT *, count_t, NodeT * > result_t
relaxed_t * ensure_mutable_relaxed_n(edit_t e, count_t n)
static void visit_leaf(Pos &&p)
static void visit_leaf(Pos &&p, Merger &merger, edit_type< Pos > e)
static void visit_regular(Pos &&p, count_t idx)
count_t counts[max_children]
static T * visit_leaf(PosT &&pos, size_t)
static result_t visit_inner(PosT &&pos, size_t idx)
typename NodeT::relaxed_t relaxed_t
static concat_center_mut_pos< Node > visit_node(LPos &&lpos, edit_t ec, edit_t el, TPos &&tpos, edit_t er, Args &&...args)
static concat_center_mut_pos< Node > visit_node(RPos &&rpos, edit_t ec, edit_t el, LPos &&lpos, TPos &&tpos, edit_t er)
static node_t * visit_regular(Pos &&pos, edit_t e, node_t *tail, Args &&...)
static result_t visit_leaf(PosT &&pos, size_t last)
auto uninitialized_move(Iter1 in1, Iter1 in2, Iter2 out)
static result_t visit_relaxed(PosT &&pos, size_t last, edit_t e)
static std::enable_if_t< is_relaxed_v< PosR >, bool > visit_regular(PosL &&posl, PosR &&posr, Iter &&first, size_t idx)
static bool visit_inner(Pos &&pos, size_t first, Fn &&fn)
static concat_center_pos< Node > visit_node(LPos &&lpos, TPos &&tpos, Args &&...args)
typename Node::edit_t edit_t
static bool visit_leaf(Pos &&pos, size_t first, Fn &&fn)
void add_child(node_t *p, size_t size)
void merge_inner(Pos &&p, edit_t e)
void set_candidate(edit_t candidate_e, node_t *candidate)
static void visit_regular(Pos &&p, count_t idx)
static node_t * visit_relaxed(Pos &&pos, node_t *tail, count_t ts)
typename std::decay< Pos >::type::node_t::edit_t edit_type
size_t sizes_[max_children]
static node_t * visit_regular(Pos &&pos, size_t idx, Fn &&fn)
static T * visit_inner(PosT &&pos, size_t idx)
static concat_center_mut_pos< Node > visit_leaf(RPos &&rpos, edit_t ec, edit_t el, LPos &&lpos, TPos &&tpos, edit_t er)
typename NodeT::value_t value_t
static concat_center_mut_pos< Node > visit_inner(RPos &&rpos, edit_t ec, edit_t el, LPos &&lpos, TPos &&tpos, edit_t er)
static void visit_relaxed(Pos &&pos, size_t first, size_t last, Fn &&fn)
typename NodeT::edit_t edit_t
static bool visit_leaf(Pos &&pos, Fn &&fn)
static constexpr auto max_children
typename Node::edit_t edit_t
relaxed_pos< Node > concat_trees(Node *lroot, shift_t lshift, size_t lsize, Node *ltail, count_t ltcount, Node *rroot, shift_t rshift, size_t rsize)
#define IMMER_UNREACHABLE
static void visit_leaf(Pos &&pos, size_t first, size_t last, Fn &&fn)
static const T & visit_inner(PosT &&pos, size_t idx)
concat_center_pos(shift_t s, Node *n0, size_t s0, Node *n1, size_t s1, Node *n2, size_t s2)
static node_t * visit_regular(Pos &&pos, node_t *tail, Args &&...)
void merge_inner(Pos &&p)
relaxed_pos< Node > realize() &&
static result_t visit_leaf(PosT &&pos, size_t first)
static concat_center_pos< Node > visit_leaf(LPos &&lpos, TPos &&tpos, RPos &&rpos)
std::tuple< T *, size_t, size_t > result_t
typename NodeT::edit_t edit_t
static void visit_relaxed(Pos &&p, count_t idx)
static result_t visit_regular(PosT &&pos, size_t first, edit_t e)
static void visit_leaf(Pos &&p, count_t idx)
static bool visit_relaxed(Pos &&pos, size_t first, size_t last, Fn &&fn)
bool can_mutate(edit_t e) const
static void visit_leaf(Pos &&pos, Fn &&fn)
static concat_center_mut_pos< Node > visit_leaf(LPos &&lpos, edit_t ec, edit_t el, TPos &&tpos, edit_t er, RPos &&rpos)
void dec_inner(NodeT *node, shift_t shift, size_t size)
void each_sub(Visitor v, Args &&...args)
decltype(auto) visit_maybe_relaxed_sub(NodeT *node, shift_t shift, size_t size, Visitor v, Args &&...args)
static void visit_leaf(Pos &&p, Merger &merger)
void dec_regular(NodeT *node, shift_t shift, size_t size)
static result_t visit_leaf(PosT &&pos, size_t last, edit_t e)
static bool visit_leaf(Pos &&pos, NodeT *other)
static void visit_inner(Pos &&p, Merger &merger)
leaf_sub_pos< NodeT > make_leaf_sub_pos(NodeT *node, count_t count)
void merge_leaf(Pos &&p, edit_t e)
concat_merger_mut(edit_t ec, shift_t shift, count_t *counts, count_t n, edit_t candidate_e, node_t *candidate)
concat_center_pos< Node > concat_inners(LPos &&lpos, TPos &&tpos, RPos &&rpos)
static node_t * visit_relaxed(Pos &&pos, size_t idx, Fn &&fn)
typename Node::edit_t edit_t
relaxed_t * ensure_mutable_relaxed(edit_t e)
static const T & visit_leaf(PosT &&pos, size_t idx)
static value_t & visit_leaf(Pos &&pos, size_t idx, edit_t e, node_t **location)
static result_t visit_regular(PosT &&pos, size_t last, edit_t e)
auto make_singleton_regular_sub_pos(NodeT *leaf, count_t count)
static concat_center_pos< Node > visit_inner(LPos &&lpos, TPos &&tpos, RPos &&rpos)
static void visit_node(Pos &&p, Plan &plan)
concat_center_mut_pos< node_type< CPos > > merge(edit_type< CPos > ec, edit_type< CPos > el, LPos &&lpos, CPos &&cpos, edit_type< CPos > er, RPos &&rpos)