directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r761396 - in /directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree: AvlTreeMap.java AvlTreeMapImpl.java
Date Thu, 02 Apr 2009 19:26:27 GMT
Author: kayyagari
Date: Thu Apr  2 19:26:27 2009
New Revision: 761396

URL: http://svn.apache.org/viewvc?rev=761396&view=rev
Log:
o added javadoc
o added license header

Modified:
    directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMap.java
    directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java

Modified: directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMap.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMap.java?rev=761396&r1=761395&r2=761396&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMap.java
(original)
+++ directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMap.java
Thu Apr  2 19:26:27 2009
@@ -1,10 +1,35 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
 package org.apache.directory.server.core.avltree;
 
 
 import java.util.Comparator;
 import java.util.List;
 
-
+/**
+ * An interface to the AVL tree based map. The implementations
+ * should hold a value(s) along with a key  
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public interface AvlTreeMap<K, V>
 {
 
@@ -24,8 +49,10 @@
      * Inserts a LinkedAvlMapNode with the given key and value.
      *
      * @param key the item to be inserted
-     * @return the replaced key if it already exists
-     * Note: Replaces a nodes value if duplicate keys are not allowed.
+     * @param value the value associated with the key
+     * @return the replaced value if any exists else null
+     * Note: Replaces a nodes value if duplicate keys are not allowed and the new value is
+     *       not equal to the existing value.
      */
     V insert( K key, V value );
 
@@ -34,14 +61,22 @@
      * Removes the LinkedAvlMapNode present in the tree with the given key and value
      *
      * @param key the key of the node to be removed
-     * @param value the value of the node, if null the entire node will be removed 
-     *              including any values having the same key
-     * @return the removed key, if any, or null if the key does not exist
+     * @param value the value of the node
+     * @return the removed value, if any, or null if the key or value does not exist
+     * @throws IllegalArgumentException if key or value is null
      */
     V remove( K key, V value );
 
-    
-    // ------ NEW ------
+
+    /**
+     * Removes a node associated with the given key
+     * The entire node will be removed irrespective of whether duplicate keys
+     * are enabled or not
+     * 
+     * @param key the key of the node to be removed
+     * @return a SingletonOrOrderedSet
+     * @throws IllegalArgumentException if key is null
+     */
     SingletonOrOrderedSet<V> remove( K key );
 
     
@@ -134,17 +169,30 @@
 
     /**
      * 
-     * Find a LinkedAvlNode with the given key value in the tree.
+     * Find a LinkedAvlMapNode with the given key value in the tree.
      *
      * @param key the key to find
-     * @return the list of traversed LinkedAvlNode.
+     * @return the list of traversed LinkedAvlMapNode.
      */
     LinkedAvlMapNode<K, V> find( K key );
 
 
+    /**
+     * 
+     * Find a LinkedAvlMapNode with the given key and value in the tree.
+     *
+     * @param key the key of the node
+     * @param value the value of the node
+     * @return LinkedAvlMapNode having the given key and value
+     */
     LinkedAvlMapNode<K, V> find( K key, V value );
 
 
+    /**
+     * tells if the duplicate keys are supported or not. 
+     *
+     * @return true if duplicate keys are allowed, false otherwise
+     */
     boolean isDupsAllowed();
 
 }
\ No newline at end of file

Modified: directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java?rev=761396&r1=761395&r2=761396&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
(original)
+++ directory/apacheds/branches/ldif-partition/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
Thu Apr  2 19:26:27 2009
@@ -26,7 +26,7 @@
 
 
 /**
- * An AVL tree implementation with support to store both key and value.
+ * An AvlTreeMap implementation with support to store both key and value.
  * This implementation also supports duplicate keys. The values of a same key
  * will be stored in a AvlTree.
  *
@@ -73,8 +73,8 @@
     }
 
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#getKeyComparator()
+    /**
+     * {@inheritDoc}
      */
     public Comparator<K> getKeyComparator()
     {
@@ -82,8 +82,8 @@
     }
     
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#getValueComparator()
+    /**
+     * {@inheritDoc}
      */
     public Comparator<V> getValueComparator()
     {
@@ -91,8 +91,8 @@
     }
     
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#insert(K, V)
+    /**
+     * {@inheritDoc}
      */
     public V insert( K key, V value )
     {
@@ -260,9 +260,7 @@
     
     
     /**
-     * removes a node associated with a key
-     * The entire node will be removed irrespective of whether duplicate keys
-     * are enabled or not
+     * {@inheritDoc}
      */
     public SingletonOrOrderedSet<V> remove( K key )
     {
@@ -297,8 +295,8 @@
     }
     
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#remove(K, V)
+    /**
+     * {@inheritDoc}
      */
     public V remove( K key, V value )
     {
@@ -468,7 +466,7 @@
      * For an excellent info please read the 
      * <a href="http://en.wikipedia.org/wiki/Avl_tree">Wikipedia article on AVL tree</a>.
      * 
-     * @param treePath the traversed list of LinkedAvlNodes after performing an insert/delete
operation.
+     * @param treePath the traversed list of LinkedAvlMapNodes after performing an insert/delete
operation.
      */
     private void balance( List<LinkedAvlMapNode<K,V>> treePath )
     {
@@ -518,8 +516,8 @@
     }
     
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#isEmpty()
+    /**
+     * {@inheritDoc}
      */
     public boolean isEmpty()
     {
@@ -527,8 +525,8 @@
     }
 
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#getSize()
+    /**
+     * {@inheritDoc}
      */
     //NOTE: This method is internally used by AVLTreeMarshaller
     public int getSize()
@@ -594,8 +592,8 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#getRoot()
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> getRoot()
     {
@@ -603,8 +601,8 @@
     }
     
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#getKeys()
+    /**
+     * {@inheritDoc}
      */
     public List<K> getKeys()
     {
@@ -620,8 +618,8 @@
         return keys;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#printTree()
+    /**
+     * {@inheritDoc}
      */
     public void printTree() 
     {
@@ -641,8 +639,8 @@
     }
     
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#getFirst()
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> getFirst()
     {
@@ -650,8 +648,8 @@
     }
 
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#getLast()
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> getLast()
     {
@@ -662,8 +660,8 @@
     /**
      * Rotate the node left side once.
      *
-     * @param node the LinkedAvlNode to be rotated
-     * @param parentNode parent LinkedAvlNode of node
+     * @param node the LinkedAvlMapNode to be rotated
+     * @param parentNode parent LinkedAvlMapNode of node
      */
     private void rotateSingleLeft(LinkedAvlMapNode<K,V> node, LinkedAvlMapNode<K,V>
parentNode)
     {
@@ -695,8 +693,8 @@
     /**
      * Rotate the node right side once.
      *
-     * @param node the LinkedAvlNode to be rotated
-     * @param parentNode parent LinkedAvlNode of node
+     * @param node the LinkedAvlMapNode to be rotated
+     * @param parentNode parent LinkedAvlMapNode of node
      */
     private void rotateSingleRight(LinkedAvlMapNode<K,V> node, LinkedAvlMapNode<K,V>
parentNode)
     {
@@ -738,10 +736,10 @@
         
 
     /**
-     * Detach a LinkedAvlNode from its parent
+     * Detach a LinkedAvlMapNode from its parent
      *
-     * @param node the LinkedAvlNode to be detached
-     * @param parentNode the parent LinkedAvlNode of the node
+     * @param node the LinkedAvlMapNode to be detached
+     * @param parentNode the parent LinkedAvlMapNode of the node
      */
     private void detachNodes(LinkedAvlMapNode<K,V> node, LinkedAvlMapNode<K,V>
parentNode)
     {
@@ -761,11 +759,11 @@
 
     /**
      * 
-     * Replace a LinkedAvlNode to be removed with a new existing LinkedAvlNode 
+     * Replace a LinkedAvlMapNode to be removed with a new existing LinkedAvlMapNode 
      *
-     * @param deleteNode the LinkedAvlNode to be deleted
-     * @param replaceNode the LinkedAvlNode to replace the deleteNode
-     * @param parentNode the parent LinkedAvlNode of deleteNode
+     * @param deleteNode the LinkedAvlMapNode to be deleted
+     * @param replaceNode the LinkedAvlMapNode to replace the deleteNode
+     * @param parentNode the parent LinkedAvlMapNode of deleteNode
      */
     private void replaceNode(LinkedAvlMapNode<K,V> deleteNode, LinkedAvlMapNode<K,V>
replaceNode, LinkedAvlMapNode<K,V> parentNode)
     {
@@ -787,12 +785,12 @@
     
     /**
      * 
-     * Find a LinkedAvlNode with the given key value in the tree starting from the startNode.
+     * Find a LinkedAvlMapNode with the given key value in the tree starting from the startNode.
      *
      * @param key the key to find
      * @param startNode starting node of a subtree/tree
      * @param path the list to be filled with traversed nodes
-     * @return the list of traversed LinkedAvlNodes.
+     * @return the list of traversed LinkedAvlMapNodes.
      */
     private List<LinkedAvlMapNode<K,V>> find( K key, LinkedAvlMapNode<K,V>
startNode, List<LinkedAvlMapNode<K,V>> path )
     {
@@ -823,8 +821,8 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#findGreater(K)
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> findGreater( K key )
     {
@@ -843,8 +841,8 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#findGreaterOrEqual(K)
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> findGreaterOrEqual( K key )
     {
@@ -863,8 +861,8 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#findLess(K)
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> findLess( K key )
     {
@@ -883,8 +881,8 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#findLessOrEqual(K)
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> findLessOrEqual( K key )
     {
@@ -932,8 +930,8 @@
         return startNode;
     }
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#find(K)
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> find( K key )
     {
@@ -941,8 +939,8 @@
     }
     
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#find(K, V)
+    /**
+     * {@inheritDoc}
      */
     public LinkedAvlMapNode<K,V> find( K key, V value )
     {
@@ -1006,10 +1004,10 @@
     
     
     /**
-     * Find the LinkedAvlNode having the max key value in the tree starting from the startNode.
+     * Find the LinkedAvlMapNode having the max key value in the tree starting from the startNode.
      *
      * @param startNode starting node of a subtree/tree
-     * @return the list of traversed LinkedAvlNodes.
+     * @return the list of traversed LinkedAvlMapNodes.
      */
     private List<LinkedAvlMapNode<K,V>> findMax( LinkedAvlMapNode<K,V>
startNode )
     {
@@ -1042,10 +1040,10 @@
 
     
     /**
-     * Find the LinkedAvlNode having the min key value in the tree starting from the startNode.
+     * Find the LinkedAvlMapNode having the min key value in the tree starting from the startNode.
      *
      * @param startNode starting node of a subtree/tree
-     * @return the list of traversed LinkedAvlNodes.
+     * @return the list of traversed LinkedAvlMapNodes.
      */
     private List<LinkedAvlMapNode<K,V>> findMin( LinkedAvlMapNode<K,V>
startNode )
     {
@@ -1078,9 +1076,9 @@
    
     
     /**
-     * Get balance-factor of the given LinkedAvlNode.
+     * Get balance-factor of the given LinkedAvlMapNode.
      *
-     * @param node a LinkedAvlNode 
+     * @param node a LinkedAvlMapNode 
      * @return balance-factor of the node
      */
     private int getBalance( LinkedAvlMapNode<K,V> node )
@@ -1135,8 +1133,8 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.avltree.AvlTreeMap#isDupsAllowed()
+    /**
+     * {@inheritDoc}
      */
     public boolean isDupsAllowed()
     {



Mime
View raw message