directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r811090 - in /directory/apacheds/branches/apacheds-schema/core-avl/src: main/java/org/apache/directory/server/core/avltree/ test/java/org/apache/directory/server/core/avltree/
Date Thu, 03 Sep 2009 19:42:26 GMT
Author: kayyagari
Date: Thu Sep  3 19:42:26 2009
New Revision: 811090

URL: http://svn.apache.org/viewvc?rev=811090&view=rev
Log:
o fixed the getSize() method in both AvlTree and AvlTreeMap
o fixed the remove(K,V) method in AvlTreeMap to return null if no value matches in the dupscontainer
o fixed the AvlTreeMap testcase

Modified:
    directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java
    directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
    directory/apacheds/branches/apacheds-schema/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapTest.java

Modified: directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java?rev=811090&r1=811089&r2=811090&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java
Thu Sep  3 19:42:26 2009
@@ -385,15 +385,17 @@
             return 1;
         }
       
-        LinkedAvlNode<K> x = first.next;
-      
+        int size = 0;
+        
+        LinkedAvlNode<K> x = first;
+        
         while( x != null )
         {
-            x.setIndex( x.previous.getIndex() + 1 );  
+            size++;
             x = x.next;
         }
-      
-        return last.getIndex() + 1;
+        
+        return size;
     }
     
     

Modified: directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java?rev=811090&r1=811089&r2=811090&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
Thu Sep  3 19:42:26 2009
@@ -336,6 +336,13 @@
                 {
                     return removedVal;//no need to balance
                 }
+                 /* 
+                  * if the value is not found then we should return
+                  */
+                else if ( removedVal == null ) 
+                {
+                    return removedVal;//no need to balance
+                }
             }
             else
             {
@@ -541,15 +548,16 @@
             return 1;
         }
       
-        LinkedAvlMapNode<K,V> x = first.next;
+        int size = 0;
+        LinkedAvlMapNode<K,V> x = first;
       
         while( x != null )
         {
-            x.setIndex( x.previous.getIndex() + 1 );  
+            size++;
             x = x.next;
         }
       
-        return last.getIndex() + 1;
+        return size;
     }
     
     

Modified: directory/apacheds/branches/apacheds-schema/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapTest.java?rev=811090&r1=811089&r2=811090&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapTest.java
Thu Sep  3 19:42:26 2009
@@ -80,7 +80,7 @@
 
         if ( LOG.isDebugEnabled() )
         {
-            tree.printTree();
+            
         }
     }
 
@@ -157,13 +157,13 @@
 
         if ( LOG.isDebugEnabled() )
         {
-            tree.printTree();
+            
         }
 
         tree.remove( 24, 3 ); // this causes a single left rotation on node with key 12
         if ( LOG.isDebugEnabled() )
         {
-            tree.printTree();
+            
         }
         assertTrue( tree.getRoot().getLeft().key == 26 );
     }
@@ -180,7 +180,7 @@
 
         if( LOG.isDebugEnabled() )
         {
-            tree.printTree();
+            
         }
         
         assertTrue( 1 == tree.insert( 3, 1 ) );// should be ignored
@@ -240,7 +240,7 @@
         
         if( LOG.isDebugEnabled() ) 
         {
-            tree.printTree();
+            
         }
     }
 
@@ -267,8 +267,8 @@
         assertEquals( 2, tree.getSize() );
         
         tree.remove( 3, 3 );
-        assertEquals("1", getInorderForm());
-        assertEquals( 1, tree.getSize() );
+        assertEquals("1,3", getInorderForm());
+        assertEquals( 2, tree.getSize() );
         
         // add some more
         tree.insert( 3, 3 );
@@ -279,8 +279,11 @@
         assertEquals("1,3", getInorderForm());
         assertEquals( 2, tree.getSize() );
         
+        tree.remove( 3, 2 );
+        tree.remove( 3, 1 );
         tree.remove( 3, 4 ); // is the last value in the dupsTree should remove the whole
         // node with key 3
+        
         assertEquals( 1, tree.getSize() );
     }
     



Mime
View raw message