directory-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=636879&view=rev
Log:
adding methods for finding >= and <= keys in addition to > and < since apacheds
relies on these and it simplifies the Table implementation code

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/main/java/org/apache/directory/server/core/avltree/LinkedAvlNode.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=636879&r1=636878&r2=636879&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 13:49:19 2008
@@ -626,9 +626,10 @@
         
         return null;
     }
-    
+
+
     /**
-     * finds a LinkedAvlNode<K> whose key is higher than the given key.
+     * Finds a LinkedAvlNode<K> whose key is higher than the given key.
      *
      * @param key the key
      * @return the LinkedAvlNode<K> whose key is greater than the given key ,<br>
@@ -646,12 +647,37 @@
         {
             return result;
         }
-        
+
         return result.next;
     }
-    
+
+
+    /**
+     * Finds a LinkedAvlNode<K> whose key is higher than the given key.
+     *
+     * @param key the key
+     * @return the LinkedAvlNode<K> whose key is greater than the given key ,<br>
+     *         null if there is no node with a higher key than the given key.
+     */
+    public LinkedAvlNode<K> findGreaterOrEqual( K key )
+    {
+        LinkedAvlNode<K> result = fetchNonNullNode( key, root, root);
+
+        if( result == null )
+        {
+            return null;
+        }
+        else if( comparator.compare( key, result.key ) <= 0 )
+        {
+            return result;
+        }
+
+        return result.next;
+    }
+
+
     /**
-     * finds a LinkedAvlNode<K> whose key is lower than the given key.
+     * Finds a LinkedAvlNode<K> whose key is lower than the given key.
      *
      * @param key the key
      * @return the LinkedAvlNode<K> whose key is lower than the given key ,<br>
@@ -669,10 +695,35 @@
         {
             return result;
         }
-        
+
         return result.previous;
     }
-    
+
+
+    /**
+     * Finds a LinkedAvlNode<K> whose key is lower than the given key.
+     *
+     * @param key the key
+     * @return the LinkedAvlNode<K> whose key is lower than the given key ,<br>
+     *         null if there is no node with a lower key than the given key.
+     */
+    public LinkedAvlNode<K> findLessOrEqual( K key )
+    {
+        LinkedAvlNode<K> result = fetchNonNullNode( key, root, root);
+
+        if( result == null )
+        {
+            return null;
+        }
+        else if( comparator.compare( key, result.key ) >= 0 )
+        {
+            return result;
+        }
+
+        return result.previous;
+    }
+
+
     /*
      * This method returns the last visited non-null node in case if the node with the given
key
      * is not present. This method should not be used as general purpose lookup method.

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/LinkedAvlNode.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/LinkedAvlNode.java?rev=636879&r1=636878&r2=636879&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/LinkedAvlNode.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/LinkedAvlNode.java
Thu Mar 13 13:49:19 2008
@@ -57,6 +57,18 @@
     }
 
 
+    public LinkedAvlNode<T> getNext()
+    {
+        return next;
+    }
+
+
+    public LinkedAvlNode<T> getPrevious()
+    {
+        return previous;
+    }
+
+
     public LinkedAvlNode<T> getLeft() {
 		return left;
 	}



Mime
View raw message