@@ -194,11 +194,10 @@ class sharing_mapt
194
194
typedef std::vector<key_type> keyst;
195
195
196
196
protected:
197
- typedef sharing_nodet<key_type, mapped_type> innert;
198
- typedef sharing_nodet<key_type, mapped_type> leaft;
197
+ typedef sharing_nodet<key_type, mapped_type> nodet;
199
198
200
- typedef typename innert ::to_mapt to_mapt;
201
- typedef typename innert ::leaf_listt leaf_listt;
199
+ typedef typename nodet ::to_mapt to_mapt;
200
+ typedef typename nodet ::leaf_listt leaf_listt;
202
201
203
202
struct falset
204
203
{
@@ -519,8 +518,8 @@ class sharing_mapt
519
518
protected:
520
519
// helpers
521
520
522
- leaft &get_leaf_node (const key_type &k);
523
- const leaft *get_leaf_node (const key_type &k) const ;
521
+ nodet &get_leaf_node (const key_type &k);
522
+ const nodet *get_leaf_node (const key_type &k) const ;
524
523
525
524
// / Move a leaf node further down the tree such as to resolve a collision with
526
525
// / another key-value pair. This method is called by `insert()` to resolve a
@@ -545,12 +544,12 @@ class sharing_mapt
545
544
const std::size_t starting_level,
546
545
const std::size_t key_suffix,
547
546
const std::size_t bit_last,
548
- innert &inner,
547
+ nodet &inner,
549
548
const key_type &k,
550
549
valueU &&m);
551
550
552
551
void iterate(
553
- const innert &n,
552
+ const nodet &n,
554
553
std::function<void (const key_type &k, const mapped_type &m)> f) const ;
555
554
556
555
// / Add a delta item to the delta view if the value in the \p container (which
@@ -568,13 +567,13 @@ class sharing_mapt
568
567
// / \param only_common: flag indicating if only items are added to the delta
569
568
// / view for which the keys are in both maps
570
569
void add_item_if_not_shared (
571
- const leaft &leaf,
572
- const innert &inner,
570
+ const nodet &leaf,
571
+ const nodet &inner,
573
572
const std::size_t level,
574
573
delta_viewt &delta_view,
575
574
const bool only_common) const ;
576
575
577
- void gather_all (const innert &n, delta_viewt &delta_view) const ;
576
+ void gather_all (const nodet &n, delta_viewt &delta_view) const ;
578
577
579
578
std::size_t count_unmarked_nodes (
580
579
bool leafs_only,
@@ -592,25 +591,25 @@ class sharing_mapt
592
591
static const std::size_t levels;
593
592
594
593
// key-value map
595
- innert map;
594
+ nodet map;
596
595
597
596
// number of elements in the map
598
597
size_type num = 0 ;
599
598
};
600
599
601
600
SHARING_MAPT (void )
602
601
::iterate(
603
- const innert &n,
602
+ const nodet &n,
604
603
std::function<void (const key_type &k, const mapped_type &m)> f) const
605
604
{
606
605
SM_ASSERT (!n.empty ());
607
606
608
- std::stack<const innert *> stack;
607
+ std::stack<const nodet *> stack;
609
608
stack.push (&n);
610
609
611
610
do
612
611
{
613
- const innert *ip = stack.top ();
612
+ const nodet *ip = stack.top ();
614
613
stack.pop ();
615
614
616
615
SM_ASSERT (!ip->empty ());
@@ -656,12 +655,12 @@ ::count_unmarked_nodes(
656
655
657
656
unsigned count = 0 ;
658
657
659
- std::stack<const innert *> stack;
658
+ std::stack<const nodet *> stack;
660
659
stack.push (&map);
661
660
662
661
do
663
662
{
664
- const innert *ip = stack.top ();
663
+ const nodet *ip = stack.top ();
665
664
SM_ASSERT (!ip->empty ());
666
665
stack.pop ();
667
666
@@ -795,7 +794,7 @@ SHARING_MAPT(void)::get_view(viewt &view) const
795
794
}
796
795
797
796
SHARING_MAPT (void )
798
- ::gather_all(const innert &n, delta_viewt &delta_view) const
797
+ ::gather_all(const nodet &n, delta_viewt &delta_view) const
799
798
{
800
799
auto f = [&delta_view](const key_type &k, const mapped_type &m) {
801
800
delta_view.push_back (delta_view_itemt (k, m));
@@ -805,8 +804,8 @@ ::gather_all(const innert &n, delta_viewt &delta_view) const
805
804
}
806
805
807
806
SHARING_MAPT (void )::add_item_if_not_shared(
808
- const leaft &leaf,
809
- const innert &inner,
807
+ const nodet &leaf,
808
+ const nodet &inner,
810
809
const std::size_t level,
811
810
delta_viewt &delta_view,
812
811
const bool only_common) const
@@ -816,7 +815,7 @@ SHARING_MAPT(void)::add_item_if_not_shared(
816
815
817
816
key >>= level * chunk;
818
817
819
- const innert *ip = &inner;
818
+ const nodet *ip = &inner;
820
819
SM_ASSERT (ip->is_defined_internal ());
821
820
822
821
while (true )
@@ -899,7 +898,7 @@ ::get_delta_view(
899
898
return ;
900
899
}
901
900
902
- typedef std::pair<const innert *, const innert *> stack_itemt;
901
+ typedef std::pair<const nodet *, const nodet *> stack_itemt;
903
902
std::stack<stack_itemt> stack;
904
903
905
904
std::stack<std::size_t > level_stack;
@@ -921,8 +920,8 @@ ::get_delta_view(
921
920
{
922
921
const stack_itemt &si = stack.top ();
923
922
924
- const innert *ip1 = si.first ;
925
- const innert *ip2 = si.second ;
923
+ const nodet *ip1 = si.first ;
924
+ const nodet *ip2 = si.second ;
926
925
927
926
SM_ASSERT (!ip1->shares_with (*ip2));
928
927
@@ -942,9 +941,9 @@ ::get_delta_view(
942
941
{
943
942
for (const auto &item : ip1->get_to_map ())
944
943
{
945
- const innert &child = item.second ;
944
+ const nodet &child = item.second ;
946
945
947
- const innert *p;
946
+ const nodet *p;
948
947
p = ip2->find_child (item.first );
949
948
950
949
if (p == nullptr )
@@ -967,7 +966,7 @@ ::get_delta_view(
967
966
968
967
for (const auto &item : ip1->get_to_map ())
969
968
{
970
- const innert &child = item.second ;
969
+ const nodet &child = item.second ;
971
970
972
971
if (!child.shares_with (*ip2))
973
972
{
@@ -1039,7 +1038,7 @@ ::get_delta_view(
1039
1038
for (const auto &l1 : ip1->get_container ())
1040
1039
{
1041
1040
const key_type &k1 = l1.get_key ();
1042
- const leaft *p;
1041
+ const nodet *p;
1043
1042
1044
1043
p = ip2->find_leaf (k1);
1045
1044
@@ -1063,12 +1062,12 @@ ::get_delta_view(
1063
1062
while (!stack.empty ());
1064
1063
}
1065
1064
1066
- SHARING_MAPT2 (, leaft &)::get_leaf_node(const key_type &k)
1065
+ SHARING_MAPT2 (, nodet &)::get_leaf_node(const key_type &k)
1067
1066
{
1068
1067
SM_ASSERT (has_key (k));
1069
1068
1070
1069
std::size_t key = hash ()(k);
1071
- innert *ip = ↦
1070
+ nodet *ip = ↦
1072
1071
SM_ASSERT (ip->is_defined_internal ());
1073
1072
1074
1073
while (true )
@@ -1095,13 +1094,13 @@ SHARING_MAPT2(, leaft &)::get_leaf_node(const key_type &k)
1095
1094
}
1096
1095
}
1097
1096
1098
- SHARING_MAPT2 (const , leaft *)::get_leaf_node(const key_type &k) const
1097
+ SHARING_MAPT2 (const , nodet *)::get_leaf_node(const key_type &k) const
1099
1098
{
1100
1099
if (empty ())
1101
1100
return nullptr ;
1102
1101
1103
1102
std::size_t key = hash ()(k);
1104
- const innert *ip = ↦
1103
+ const nodet *ip = ↦
1105
1104
SM_ASSERT (ip->is_defined_internal ());
1106
1105
1107
1106
while (true )
@@ -1139,11 +1138,11 @@ SHARING_MAPT(void)::erase(const key_type &k)
1139
1138
{
1140
1139
SM_ASSERT (has_key (k));
1141
1140
1142
- innert *del = nullptr ;
1141
+ nodet *del = nullptr ;
1143
1142
std::size_t del_bit = 0 ;
1144
1143
1145
1144
std::size_t key = hash ()(k);
1146
- innert *ip = ↦
1145
+ nodet *ip = ↦
1147
1146
1148
1147
while (true )
1149
1148
{
@@ -1206,23 +1205,23 @@ ::migrate(
1206
1205
const std::size_t starting_level,
1207
1206
const std::size_t key_suffix,
1208
1207
const std::size_t bit_last,
1209
- innert &inner,
1208
+ nodet &inner,
1210
1209
const key_type &k,
1211
1210
valueU &&m)
1212
1211
{
1213
1212
SM_ASSERT (starting_level < levels - 1 );
1214
1213
SM_ASSERT (inner.is_defined_internal ());
1215
1214
1216
- leaft &leaf = inner.add_child (bit_last);
1215
+ nodet &leaf = inner.add_child (bit_last);
1217
1216
SM_ASSERT (leaf.is_defined_leaf ());
1218
1217
1219
1218
std::size_t key_existing = hash ()(leaf.get_key ());
1220
1219
key_existing >>= chunk * starting_level;
1221
1220
1222
- leaft leaf_kept;
1221
+ nodet leaf_kept;
1223
1222
leaf_kept.swap (leaf);
1224
1223
1225
- innert *ip = &leaf;
1224
+ nodet *ip = &leaf;
1226
1225
SM_ASSERT (ip->empty ());
1227
1226
1228
1227
// Find place for both elements
@@ -1246,11 +1245,11 @@ ::migrate(
1246
1245
{
1247
1246
// Place found
1248
1247
1249
- innert &l1 = ip->add_child (bit_existing);
1248
+ nodet &l1 = ip->add_child (bit_existing);
1250
1249
SM_ASSERT (l1.empty ());
1251
1250
l1.swap (leaf_kept);
1252
1251
1253
- innert &l2 = ip->add_child (bit);
1252
+ nodet &l2 = ip->add_child (bit);
1254
1253
SM_ASSERT (l2.empty ());
1255
1254
l2.make_leaf (k, std::forward<valueU>(m));
1256
1255
@@ -1285,7 +1284,7 @@ ::insert(const key_type &k, valueU &&m)
1285
1284
SM_ASSERT (!has_key (k));
1286
1285
1287
1286
std::size_t key = hash ()(k);
1288
- innert *ip = ↦
1287
+ nodet *ip = ↦
1289
1288
1290
1289
// The root must be an internal node
1291
1290
SM_ASSERT (ip->is_internal ());
@@ -1300,7 +1299,7 @@ ::insert(const key_type &k, valueU &&m)
1300
1299
SM_ASSERT (ip->is_internal ());
1301
1300
SM_ASSERT (level == 0 || !ip->empty ());
1302
1301
1303
- innert &child = ip->add_child (bit);
1302
+ nodet &child = ip->add_child (bit);
1304
1303
1305
1304
// Place is unoccupied
1306
1305
if (child.empty ())
@@ -1359,7 +1358,7 @@ ::insert(const key_type &k, valueU &&m)
1359
1358
SHARING_MAPT4 (valueU, void )
1360
1359
::replace(const key_type &k, valueU &&m)
1361
1360
{
1362
- leaft &lp = get_leaf_node (k);
1361
+ nodet &lp = get_leaf_node (k);
1363
1362
1364
1363
INVARIANT (
1365
1364
!value_equalt ()(as_const (lp).get_value (), m),
@@ -1371,7 +1370,7 @@ ::replace(const key_type &k, valueU &&m)
1371
1370
SHARING_MAPT (void )
1372
1371
::update(const key_type &k, std::function<void (mapped_type &)> mutator)
1373
1372
{
1374
- leaft &lp = get_leaf_node (k);
1373
+ nodet &lp = get_leaf_node (k);
1375
1374
1376
1375
value_comparatort comparator (as_const (lp).get_value ());
1377
1376
@@ -1386,7 +1385,7 @@ ::update(const key_type &k, std::function<void(mapped_type &)> mutator)
1386
1385
SHARING_MAPT2 (optionalt<std::reference_wrapper<const , mapped_type>>)::find(
1387
1386
const key_type &k) const
1388
1387
{
1389
- const leaft *lp = get_leaf_node (k);
1388
+ const nodet *lp = get_leaf_node (k);
1390
1389
1391
1390
if (lp == nullptr )
1392
1391
return {};
0 commit comments