directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r660290 - in /directory/apacheds/branches/bigbang/core-avl/src: main/java/org/apache/directory/server/core/avltree/AvlTree.java test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
Date Mon, 26 May 2008 20:08:58 GMT
Author: kayyagari
Date: Mon May 26 13:08:54 2008
New Revision: 660290

URL: http://svn.apache.org/viewvc?rev=660290&view=rev
Log:
AvlTree - fixed an issue with hard coded null value while detaching two nodes
AvlTreeTest - added a test case for the above fix

Modified:
    directory/apacheds/branches/bigbang/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
    directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java

Modified: directory/apacheds/branches/bigbang/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java?rev=660290&r1=660289&r2=660290&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
(original)
+++ directory/apacheds/branches/bigbang/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
Mon May 26 13:08:54 2008
@@ -568,7 +568,7 @@
 	    {
 	        if( node == parentNode.left )
 	        {
-	            parentNode.left = null;
+	            parentNode.left = node.left;
 	        }
 	        else if( node == parentNode.right )
 	        {

Modified: directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java?rev=660290&r1=660289&r2=660290&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
(original)
+++ directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
Mon May 26 13:08:54 2008
@@ -400,10 +400,29 @@
         }
 
         tree.remove( 13 );
-
+        
         assertEquals( 11, ( int ) tree.find( 8 ).right.key );
     }
 
+   
+    @Test
+    public void testRemoveInLeftSubtree()
+    {
+        int[] keys = { 8, 4, 12, 6, 7, 16, 10, 5, 11, 9, 17, 5, 14, 2, 13, 1, 3 }; // order
is important to produce the expected tree
+        
+        for( int key:keys )
+        {
+            tree.insert( key );
+        }
+
+        tree.remove( 16 );
+
+        assertEquals( 8, ( int ) tree.getRoot().key );
+        assertEquals( 12, ( int ) tree.getRoot().right.key );
+        assertEquals( 14, ( int ) tree.getRoot().right.right.key );
+        assertEquals( 13, ( int ) tree.find( 14 ).left.key );
+    }
+    
     
     private String getLinkedText() 
     {



Mime
View raw message