@@ -524,27 +524,27 @@ unittest heap {
524
524
}
525
525
526
526
void checkIntegrity () {
527
- void check (Link n, Link prev, Link parent) {
527
+ auto root = heap.root;
528
+ assert (heap.top is root.node);
529
+
530
+ static void check (Link root, Link n, Link prev, Link parent) {
528
531
if (n.isNull()) {
529
532
return ;
530
533
}
531
534
532
- assert (n.node is heap.top || stuffCmp(heap.top, n.node) < 0 );
533
- assert (parent.isNull() || stuffCmp(parent.node, n.node) < 0 );
535
+ auto top = root.node;
536
+ assert (n.node is top || stuffCmp(top, n.node) < 0 );
537
+ assert (n.node is top || stuffCmp(parent.node, n.node) < 0 );
534
538
535
539
// /!\ The root's prev is not maintained.
536
540
assert (prev.isNull() || n.prev.node is prev.node);
537
- check(n.next, n, parent);
538
- check(n.child, n, n);
541
+ check(root, n.next, n, parent);
542
+ check(root, n.child, n, n);
539
543
}
540
544
541
- auto root = heap.root;
542
- check(root, Link (null ), Link(null ));
543
-
544
- // Check that all elements in the aux list are smaller than the root.
545
- if (! root.isNull()) {
546
- check(root.next, root, root);
547
- }
545
+ // /!\ Passing root as parent to check the aux list is
546
+ // made of elements smaller than the root.
547
+ check(root, root, Link(null ), root);
548
548
}
549
549
550
550
void checkHeap () {
0 commit comments