@@ -453,7 +453,7 @@ class sharing_mapt
453
453
if (empty ())
454
454
return ;
455
455
456
- iterate(map, 0 , f);
456
+ iterate(map, f);
457
457
}
458
458
459
459
#if !defined(_MSC_VER)
@@ -525,12 +525,10 @@ class sharing_mapt
525
525
}
526
526
527
527
void iterate(
528
- const baset &n,
529
- const unsigned start_depth,
528
+ const innert &n,
530
529
std::function<void (const key_type &k, const mapped_type &m)> f) const ;
531
530
532
- void gather_all (const baset &n, const unsigned depth, delta_viewt &delta_view)
533
- const ;
531
+ void gather_all (const innert &n, delta_viewt &delta_view) const ;
534
532
535
533
std::size_t count_unmarked_nodes (
536
534
bool leafs_only,
@@ -559,42 +557,37 @@ class sharing_mapt
559
557
560
558
SHARING_MAPT (void )
561
559
::iterate(
562
- const baset &n,
563
- unsigned start_depth,
560
+ const innert &n,
564
561
std::function<void (const key_type &k, const mapped_type &m)> f) const
565
562
{
566
- typedef std::pair< unsigned , const baset *> stack_itemt ;
563
+ SM_ASSERT (!n. empty ()) ;
567
564
568
- std::stack<stack_itemt > stack;
569
- stack.push ({start_depth, &n} );
565
+ std::stack<const innert * > stack;
566
+ stack.push (&n );
570
567
571
568
do
572
569
{
573
- const stack_itemt &si = stack.top ();
574
-
575
- const unsigned depth = si.first ;
576
- const baset *bp = si.second ;
577
-
570
+ const innert *ip = stack.top ();
578
571
stack.pop ();
579
572
580
- if (depth < steps) // internal
573
+ SM_ASSERT (!ip->empty ());
574
+
575
+ if (ip->is_internal ())
581
576
{
582
- const innert *ip = static_cast <const innert *>(bp);
583
577
const to_mapt &m = ip->get_to_map ();
584
578
SM_ASSERT (!m.empty ());
585
579
586
580
for (const auto &item : m)
587
581
{
588
582
const innert *i = &item.second ;
589
- stack.push ({depth + 1 , i} );
583
+ stack.push (i );
590
584
}
591
585
}
592
- else // container
586
+ else
593
587
{
594
- SM_ASSERT (depth == steps );
588
+ SM_ASSERT (ip-> is_container () );
595
589
596
- const innert *cp = static_cast <const innert *>(bp);
597
- const leaf_listt &ll = cp->get_container ();
590
+ const leaf_listt &ll = ip->get_container ();
598
591
SM_ASSERT (!ll.empty ());
599
592
600
593
for (const auto &l : ll)
@@ -766,17 +759,17 @@ SHARING_MAPT(void)::get_view(viewt &view) const
766
759
view.push_back (view_itemt (k, m));
767
760
};
768
761
769
- iterate(map, 0 , f);
762
+ iterate(map, f);
770
763
}
771
764
772
765
SHARING_MAPT (void )
773
- ::gather_all(const baset &n, unsigned depth , delta_viewt &delta_view) const
766
+ ::gather_all(const innert &n, delta_viewt &delta_view) const
774
767
{
775
768
auto f = [&delta_view](const key_type &k, const mapped_type &m) {
776
769
delta_view.push_back (delta_view_itemt (false , k, m, dummy));
777
770
};
778
771
779
- iterate(n, depth, f);
772
+ iterate(n, f);
780
773
}
781
774
782
775
SHARING_MAPT (void )
@@ -794,7 +787,7 @@ ::get_delta_view(
794
787
{
795
788
if (!only_common)
796
789
{
797
- gather_all (map, 0 , delta_view);
790
+ gather_all (map, delta_view);
798
791
}
799
792
800
793
return ;
@@ -838,7 +831,7 @@ ::get_delta_view(
838
831
{
839
832
if (!only_common)
840
833
{
841
- gather_all (item.second , depth + 1 , delta_view);
834
+ gather_all (item.second , delta_view);
842
835
}
843
836
}
844
837
else if (!item.second .shares_with (*p))
0 commit comments