• R/O
  • SSH
  • HTTPS

eirrepo: Commit


Commit MetaInfo

Revision95 (tree)
Time2018-05-11 03:57:26
Authorquiret

Log Message

- fixed some AVLTree bugs that I remembered
- minor adjustments

Change Summary

Incremental Difference

--- unittests/src/avltree.cpp (revision 94)
+++ unittests/src/avltree.cpp (revision 95)
@@ -75,5 +75,5 @@
7575 check_sort();
7676 }
7777 }
78- printf( "OK.\n" );
78+ printf( "ok.\n" );
7979 }
\ No newline at end of file
--- common/sdk/AVLTree.h (revision 94)
+++ common/sdk/AVLTree.h (revision 95)
@@ -272,8 +272,7 @@
272272 break;
273273 }
274274
275- // Set a new parent.
276- parent = iter;
275+ AVLNode *newParent = iter;
277276
278277 // Check key condition.
279278 if ( is_node_less_than( node, iter ) )
@@ -291,6 +290,9 @@
291290 // Quit because we found the node.
292291 break;
293292 }
293+
294+ // Update the parent.
295+ parent = newParent;
294296 }
295297
296298 iterPtrOut = iterPtr;
@@ -367,10 +369,20 @@
367369 if ( leftChild == nullptr )
368370 {
369371 *nodePtr = rightChild;
372+
373+ if ( rightChild != nullptr )
374+ {
375+ rightChild->parent = parent;
376+ }
370377 }
371378 else if ( rightChild == nullptr )
372379 {
373380 *nodePtr = leftChild;
381+
382+ if ( leftChild != nullptr )
383+ {
384+ leftChild->parent = parent;
385+ }
374386 }
375387 else
376388 {
Show on old repository browser