directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r636834 - in /directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src: main/java/org/apache/directory/server/core/avltree/AvlTree.java test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
Date Thu, 13 Mar 2008 19:00:21 GMT
Author: akarasulu
Date: Thu Mar 13 12:00:20 2008
New Revision: 636834

URL: http://svn.apache.org/viewvc?rev=636834&view=rev
Log:
[REVERT] temporarily reverting changes made in commit 636469 until the issues are resolved

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

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java?rev=636834&r1=636833&r2=636834&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
Thu Mar 13 12:00:20 2008
@@ -45,8 +45,6 @@
 	/** node representing the end of the doubly linked list formed with the tree nodes */
     private LinkedAvlNode<K> last;
 
-    /** holds the number of nodes present in the tree */
-    private int size;
 
 
     /**
@@ -80,11 +78,10 @@
 	    
 	    if( root == null )
 	    {
-	        root = new LinkedAvlNode<K>( key );
-	        first = root;
-	        last = root;
-	        size = 1;
-	        return null;
+	      root = new LinkedAvlNode<K>( key );
+	      first = root;
+	      last = root;
+	      return null;
 	    }
 	    
 	    node = new LinkedAvlNode<K>( key );
@@ -131,8 +128,6 @@
         treePath.add( 0, node );
 	    balance(treePath);
 	    
-	    size++;
-	    
 	    return null;
 	}
 	
@@ -232,7 +227,6 @@
             if( temp == root )
             {
               root = null;
-              size = 0;
               return key;
             }
             
@@ -306,8 +300,6 @@
        treePath.add( 0, y ); // y can be null but getBalance returns 0 so np
        balance( treePath );
        
-       size--;
-       
        return key;
     }
     
@@ -390,7 +382,25 @@
     //NOTE: This method is internally used by AVLTreeMarshaller
     public int getSize()
     {
-        return size;
+        if ( root == null )
+        {
+            return 0;
+        }
+        
+        if( root.isLeaf() )
+        {
+            return 1;
+        }
+      
+        LinkedAvlNode<K> x = first.next;
+      
+        while( x != null )
+        {
+            x.setIndex( x.previous.getIndex() + 1 );  
+            x = x.next;
+        }
+      
+        return last.getIndex() + 1;
     }
     
     

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java?rev=636834&r1=636833&r2=636834&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
Thu Mar 13 12:00:20 2008
@@ -388,32 +388,6 @@
       return sb.toString();
     }
     
-    @Test
-    public void testSize()
-    {
-        assertTrue( 0 == tree.getSize() );
-        
-        tree.insert( 3 );
-        assertTrue( 1 == tree.getSize() );
-        
-        tree.remove( 3 );
-        assertTrue( 0 == tree.getSize() );
-        
-        tree.insert( 0 );
-        tree.insert( 7 );
-        tree.insert( 3 );
-        assertTrue( 3 == tree.getSize() );
-        
-        tree.remove( 0 );
-        assertTrue( 2 == tree.getSize() );
-        
-        tree.remove( 7 );
-        tree.remove( 3 );
-        
-        assertTrue( 0 == tree.getSize() );
-    }
-    
-    
     private void traverse( LinkedAvlNode<Integer> startNode, List<LinkedAvlNode<Integer>>
path )
     {
       //1. pre-order



Mime
View raw message