directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r637632 - in /directory/sandbox/akarasulu/bigbang/apacheds: btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-store/src/...
Date Sun, 16 Mar 2008 19:39:11 GMT
Author: akarasulu
Date: Sun Mar 16 12:39:10 2008
New Revision: 637632

URL: http://svn.apache.org/viewvc?rev=637632&view=rev
Log:
changes to Table interface

 o for clarity the has(K,V,boolean) method has been split into two methods
    - hasGreaterOrEqual(K,V) 
    - hasLessOrEqual(K,V)
 o modified javadocs and tests to reflect these changes


Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java?rev=637632&r1=637631&r2=637632&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java
Sun Mar 16 12:39:10 2008
@@ -132,26 +132,62 @@
 
 
     /**
-     * Checks to see if this table has a record with a key greater/less than or
+     * Checks to see if this table has a record with a key greater than or
      * equal to the key argument.  The key argument need not exist for this
      * call to return true.  The underlying database must sort keys based on a
      * key comparator because this method depends on key ordering.
      *
      * @param key the key to compare keys to
-     * @param isGreaterThan boolean for greater than or less then comparison
-     * @return true if a record with a key greater/less than the key argument
-     * exists, false otherwise
+     * @return true if a Tuple with a key greater than or equal to the key
+     * argument exists, false otherwise
      * @throws Exception if there is a failure to read the underlying Db
      */
-    boolean has( K key, boolean isGreaterThan ) throws Exception;
+    boolean hasGreaterOrEqual( K key ) throws Exception;
 
 
     /**
-     * Checks to see if this table has a record with a key equal to the
-     * argument key with a value greater/less than or equal to the value
-     * argument provided.  The key argument <strong>MUST</strong> exist for
-     * this call to return true and the underlying Db must allows for sorted
-     * duplicate values.  The entire basis to this method depends on the fact
+     * Checks to see if this table has a record with a key less than or
+     * equal to the key argument.  The key argument need not exist for this
+     * call to return true.  The underlying database must sort keys based on a
+     * key comparator because this method depends on key ordering.
+     *
+     * @param key the key to compare keys to
+     * @return true if a Tuple with a key less than or equal to the key
+     * argument exists, false otherwise
+     * @throws Exception if there is a failure to read the underlying Db
+     */
+    boolean hasLessOrEqual( K key ) throws Exception;
+
+
+    /**
+     * Checks to see if this table has a Tuple with a key equal to the key
+     * argument, yet with a value greater than or equal to the value argument
+     * provided.  The key argument <strong>MUST</strong> exist for this call
+     * to return true and the underlying Db must allow for values of duplicate
+     * keys to be sorted.  The entire basis to this method depends on the fact
+     * that tuples of the same key have values sorted according to a valid
+     * value comparator.
+     *
+     * If the table does not support duplicates then an
+     * UnsupportedOperationException is thrown.
+     *
+     * @param key the key
+     * @param val the value to compare values to
+     * @return true if a Tuple with a key equal to the key argument and a
+     * value greater than the value argument exists, false otherwise
+     * @throws Exception if there is a failure to read the underlying Db
+     * or if the underlying Db is not of the Btree type that allows sorted
+     * duplicate values.
+     */
+    boolean hasGreaterOrEqual( K key, V val ) throws Exception;
+
+
+    /**
+     * Checks to see if this table has a Tuple with a key equal to the key
+     * argument, yet with a value less than or equal to the value argument
+     * provided.  The key argument <strong>MUST</strong> exist for this call
+     * to return true and the underlying Db must allow for values of duplicate
+     * keys to be sorted.  The entire basis to this method depends on the fact
      * that tuples of the same key have values sorted according to a valid
      * value comparator.
      *
@@ -160,14 +196,13 @@
      *
      * @param key the key
      * @param val the value to compare values to
-     * @param isGreaterThan boolean for greater than or less then comparison
-     * @return true if a record with a key greater/less than the key argument
-     * exists, false otherwise
+     * @return true if a Tuple with a key equal to the key argument and a
+     * value less than the value argument exists, false otherwise
      * @throws Exception if there is a failure to read the underlying Db
      * or if the underlying Db is not of the Btree type that allows sorted
      * duplicate values.
      */
-    boolean has( K key, V val, boolean isGreaterThan ) throws Exception;
+    boolean hasLessOrEqual( K key, V val ) throws Exception;
 
 
     // ------------------------------------------------------------------------

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=637632&r1=637631&r2=637632&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
Sun Mar 16 12:39:10 2008
@@ -491,7 +491,14 @@
      */
     public boolean hasValue( K attrVal, Long id, boolean isGreaterThan ) throws IOException
     {
-        return forward.has( getNormalized( attrVal ), id, isGreaterThan );
+        if ( isGreaterThan )
+        {
+            return forward.hasGreaterOrEqual( getNormalized( attrVal ), id );
+        }
+        else
+        {
+            return forward.hasLessOrEqual( getNormalized( attrVal ), id );
+        }
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=637632&r1=637631&r2=637632&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
Sun Mar 16 12:39:10 2008
@@ -386,28 +386,23 @@
 
     public V get( K key ) throws IOException
     {
+        if ( key == null )
+        {
+            return null;
+        }
+
         if ( ! allowsDuplicates )
         {
             return getNoDups( key );
         }                         
 
         DupsContainer values = getDups( key );
-        
-        if ( values == null )
-        {
-            return null;
-        }
-        
+
         if ( values.isAvlTree() )
         {
             //noinspection unchecked
             AvlTree<V> set = values.getAvlTree();
 
-            if ( set == null )
-            {
-                return null;
-            }
-            
             if ( set.getFirst() == null )
             {
                 return null;
@@ -418,103 +413,78 @@
 
         // Handle values if they are stored in another BTree
         BTree tree = getBTree( values.getBTreeRedirect() );
-        
-        if ( tree.size() == 0 )
-        {
-            return null;
-        }
-        else
-        {
-            return firstKey( tree );
-        }
+        return firstKey( tree );
     }
 
     
     /**
-     * @see Table#has(java.lang.Object,
-     * java.lang.Object, boolean)
+     * @see Table#hasGreaterOrEqual(Object,Object)
      */
     @SuppressWarnings("unchecked")
-    public boolean has( K key, V val, boolean isGreaterThan ) throws IOException
+    public boolean hasGreaterOrEqual( K key, V val ) throws IOException
     {
-        if ( !allowsDuplicates )
+        if ( key == null )
         {
-            Object rval = getNoDups( key );
+            return false;
+        }
 
-            // key does not exist so return nothing
-            if ( null == rval )
-            {
-                return false;
-            }
-            // val == val return true
-            else if ( val.equals( rval ) )
-            {
-                return true;
-            }
-            
-            /*
-             * Any comparisons below here would require use to use a value 
-             * comparator to determine ordering.  However since this Table
-             * has duplicate keys disabled (multiple values), there is no
-             * way to set a value comparator.  Perhaps this can change but 
-             * for now this will throw an unsupported operation exception.
-             * 
-             * If a value comparator is available then the following code 
-             * below will allow us to return the correct values.
-             */
-            
+        if ( ! allowsDuplicates )
+        {
             throw new UnsupportedOperationException( "Unfortunately this Table without duplicates
enabled " +
             		"does not contain a value comparator which is needed to answer your ordering
question." );
-            
-//            // val >= val and test is for greater then return true
-//            else if ( comparator.compareValue( ( V ) rval, val ) >= 1 && isGreaterThan
)
-//            {
-//                return true;
-//            }
-//            // val <= val and test is for lesser then return true
-//            else if ( comparator.compareValue( ( V ) rval, val ) <= 1 && !isGreaterThan
)
-//            {
-//                return true;
-//            }
-//
-//            return false;
-            
         }
 
         DupsContainer values = getDups( key );
-        
-        if ( values == null )
+
+        if ( values.isAvlTree() )
+        {
+            AvlTree<V> set = values.getAvlTree();
+            LinkedAvlNode<V> result = set.findGreaterOrEqual( val );
+            return result != null;
+        }
+
+        // last option is to try a btree with BTreeRedirects
+        BTree tree = getBTree( values.getBTreeRedirect() );
+        return tree.size() != 0 && btreeHas( tree, val, true );
+    }
+
+
+    /**
+     * @see Table#hasLessOrEqual(Object,Object)
+     */
+    @SuppressWarnings("unchecked")
+    public boolean hasLessOrEqual( K key, V val ) throws IOException
+    {
+        if ( key == null )
         {
             return false;
         }
-        
+
+        if ( ! allowsDuplicates )
+        {
+            throw new UnsupportedOperationException( "Unfortunately this Table without duplicates
enabled " +
+            		"does not contain a value comparator which is needed to answer your ordering
question." );
+        }
+
+        DupsContainer values = getDups( key );
+
         if ( values.isAvlTree() )
         {
             AvlTree<V> set = values.getAvlTree();
-            LinkedAvlNode<V> result;
-    
-            if ( isGreaterThan )
-            {
-                result = set.findGreaterOrEqual( val );
-            }
-            else
-            {
-                result = set.findLessOrEqual( val );
-            }
-
+            LinkedAvlNode<V> result = set.findLessOrEqual( val );
             return result != null;
         }
-        
+
         // last option is to try a btree with BTreeRedirects
         BTree tree = getBTree( values.getBTreeRedirect() );
-        return tree.size() != 0 && btreeHas( tree, val, isGreaterThan );
+        return tree.size() != 0 && btreeHas( tree, val, false );
     }
-    
+
 
     /**
-     * @see Table#has(java.lang.Object, boolean)
+     * @see Table#hasGreaterOrEqual(Object)
      */
-    public boolean has( K key, boolean isGreaterThan ) throws IOException
+    public boolean hasGreaterOrEqual( K key ) throws IOException
     {
         // See if we can find the border between keys greater than and less
         // than in the set of keys.  This will be the spot we search from.
@@ -528,19 +498,34 @@
         }
 
         // Greater searches are easy and quick thanks to findGreaterOrEqual
-        if ( isGreaterThan )
+        // A null return above means there were no equal or greater keys
+        if ( null == tuple )
         {
-            // A null return above means there were no equal or greater keys
-            if ( null == tuple )
-            {
-                return false;
-            }
+            return false;
+        }
+
+        // Not Null! - we found a tuple with equal or greater key value
+        return true;
+    }
+
+
+    /**
+     * @see Table#hasLessOrEqual(Object)
+     */
+    public boolean hasLessOrEqual( K key ) throws IOException
+    {
+        // See if we can find the border between keys greater than and less
+        // than in the set of keys.  This will be the spot we search from.
+        jdbm.helper.Tuple tuple = bt.findGreaterOrEqual( key );
 
-            // Not Null! - we found a tuple with equal or greater key value
+        // Test for equality first since it satisfies both greater/less than
+        //noinspection unchecked
+        if ( null != tuple && keyComparator.compare( ( K ) tuple.getKey(), key )
== 0 )
+        {
             return true;
         }
 
-        // Less than searches occur below and are not as efficient or easy.
+        // Less than searches are not as efficient or easy as greaterOrEqual.
         // We need to scan up from the begining if findGreaterOrEqual failed
         // or scan down if findGreaterOrEqual succeed.
         TupleBrowser browser;
@@ -602,6 +587,11 @@
      */
     public boolean has( K key, V value ) throws IOException
     {
+        if ( key == null )
+        {
+            return false;
+        }
+
         if ( ! allowsDuplicates )
         {
             V stored = getNoDups( key );
@@ -609,11 +599,6 @@
         }
         
         DupsContainer values = getDups( key );
-        
-        if ( values == null )
-        {
-            return false;
-        }
         
         if ( values.isAvlTree() )
         {

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java?rev=637632&r1=637631&r2=637632&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
Sun Mar 16 12:39:10 2008
@@ -61,6 +61,7 @@
     @Before
     public void createTable() throws Exception
     {
+        destryTable();
         File tmpDir = null;
         if ( System.getProperty( TEST_OUTPUT_PATH, null ) != null )
         {
@@ -80,11 +81,25 @@
     @After
     public void destryTable() throws Exception
     {
-        table.close();
+        if ( table != null )
+        {
+            table.close();
+        }
+
         table = null;
-        recman.close();
+
+        if ( recman != null )
+        {
+            recman.close();
+        }
+
         recman = null;
-        dbFile.deleteOnExit();
+
+        if ( dbFile != null )
+        {
+            dbFile.delete();
+        }
+        
         dbFile = null;
     }
     
@@ -138,10 +153,26 @@
         // Test has operations
         assertFalse( table.has( 1 ) );
         assertFalse( table.has( 1, 0 ) );
-        assertFalse( table.has( 1, true ) );
-        assertFalse( table.has( 1, false ) );
-        assertFalse( table.has( 1, 0, true ) );
-        assertFalse( table.has( 1, 0, false ) );
+        assertFalse( table.hasGreaterOrEqual( 1 ) );
+        assertFalse( table.hasLessOrEqual( 1 ) );
+
+        try
+        {
+            assertFalse( table.hasGreaterOrEqual( 1, 0 ) );
+            fail( "Should never get here." );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+        }
+
+        try
+        {
+            assertFalse( table.hasLessOrEqual( 1, 0 ) );
+            fail( "Should never get here." );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+        }
     }
 
     
@@ -234,27 +265,42 @@
         assertEquals( SIZE, table.count() );
 
         assertFalse( table.has( -1 ) );
-        assertTrue( table.has( -1 , true ) );
-        assertFalse( table.has( -1 , false ) );
+        assertTrue( table.hasGreaterOrEqual( -1 ) );
+        assertFalse( table.hasLessOrEqual( -1 ) );
         
         assertTrue( table.has( 0 ) );
-        assertTrue( table.has( 0 , true ) );
-        assertTrue( table.has( 0 , false ) );
+        assertTrue( table.hasGreaterOrEqual( 0 ) );
+        assertTrue( table.hasLessOrEqual( 0 ) );
         
-        assertTrue( table.has( SIZE-1 ) );
-        assertTrue( table.has( SIZE-1, true ) );
-        assertTrue( table.has( SIZE-1, false ) );
+        assertTrue( table.has( SIZE - 1 ) );
+        assertTrue( table.hasGreaterOrEqual( SIZE - 1 ) );
+        assertTrue( table.hasLessOrEqual( SIZE - 1 ) );
         
         assertFalse( table.has( SIZE ) );
-        assertFalse( table.has( SIZE, true ) );
-        assertTrue( table.has( SIZE, false ) );
-        
-        assertTrue( table.has( 1, 1, true ) );
-        assertTrue( table.has( 1, 1, false ) );
+        assertFalse( table.hasGreaterOrEqual( SIZE ) );
+        assertTrue( table.hasLessOrEqual( SIZE ) );
         
         try
         {
-            assertTrue( table.has( 1, 2, false ) );
+            assertFalse( table.hasGreaterOrEqual( 1, 1 ) );
+            fail( "Should never get here." );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+        }
+
+        try
+        {
+            assertFalse( table.hasLessOrEqual( 1, 1 ) );
+            fail( "Should never get here." );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+        }
+
+        try
+        {
+            assertTrue( table.hasLessOrEqual( 1, 2 ) );
             fail( "Should never get here since no dups tables " +
             		"freak when they cannot find a value comparator" );
         } 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java?rev=637632&r1=637631&r2=637632&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java
Sun Mar 16 12:39:10 2008
@@ -63,6 +63,7 @@
     @Before 
     public void createTable() throws Exception
     {
+        destryTable();
         File tmpDir = null;
         if ( System.getProperty( TEST_OUTPUT_PATH, null ) != null )
         {
@@ -86,11 +87,25 @@
     @After
     public void destryTable() throws Exception
     {
-        table.close();
+        if ( table != null )
+        {
+            table.close();
+        }
+
         table = null;
-        recman.close();
+
+        if ( recman != null )
+        {
+            recman.close();
+        }
+
         recman = null;
-        dbFile.deleteOnExit();
+
+        if ( dbFile != null )
+        {
+            dbFile.delete();
+        }
+
         dbFile = null;
     }
 
@@ -104,9 +119,10 @@
 
 
     @Test
-    public void testCountOneArgNoValues() throws Exception
+    public void testCountOneArg() throws Exception
     {
         assertEquals( 0, table.count( 3 ) );
+        assertEquals( 0, table.count( null ) );
     }
 
 
@@ -177,17 +193,18 @@
 
         // Test get method
         assertNull( table.get( 0 ) );
-        
+        assertNull( table.get( null ) );
+
         // Test remove methods
         assertNull( table.remove( 1 ) );
         
         // Test has operations
         assertFalse( table.has( 1 ) );
         assertFalse( table.has( 1, 0 ) );
-        assertFalse( table.has( 1, true ) );
-        assertFalse( table.has( 1, false ) );
-        assertFalse( table.has( 1, 0, true ) );
-        assertFalse( table.has( 1, 0, false ) );
+        assertFalse( table.hasGreaterOrEqual( 1 ) );
+        assertFalse( table.hasLessOrEqual( 1 ) );
+        assertFalse( table.hasGreaterOrEqual( 1, 0 ) );
+        assertFalse( table.hasLessOrEqual( 1, 0 ) );
     }
     
     
@@ -206,15 +223,15 @@
         assertTrue( table.has( 1, 0 ) );
         assertFalse( table.has( 1, SIZE ) );
 
-        assertTrue( table.has( 1, 0, true ) );
-        assertTrue( table.has( 1, 0, false ) );
-        assertFalse( table.has( 1, -1, false ) );
-
-        assertTrue( table.has( 1, SIZE-1, true ) );
-        assertTrue( table.has( 1, SIZE-1, false ) );
-        assertTrue( table.has( 1, SIZE-1, true ) );
-        assertTrue( table.has( 1, SIZE, false ) );
-        assertFalse( table.has( 1, SIZE, true ) );
+        assertTrue( table.hasGreaterOrEqual( 1, 0 ) );
+        assertTrue( table.hasLessOrEqual( 1, 0 ) );
+        assertFalse( table.hasLessOrEqual( 1, -1 ) );
+
+        assertTrue( table.hasGreaterOrEqual( 1, SIZE - 1 ) );
+        assertTrue( table.hasLessOrEqual( 1, SIZE - 1 ) );
+        assertTrue( table.hasGreaterOrEqual( 1, SIZE - 1 ) );
+        assertTrue( table.hasLessOrEqual( 1, SIZE ) );
+        assertFalse( table.hasGreaterOrEqual( 1, SIZE ) );
         assertFalse( table.has( 1, SIZE ) );
 
         // let's go over the this limit now and ask the same questions
@@ -223,22 +240,23 @@
         assertTrue( table.has( 1 ) );
         assertTrue( table.has( 1, 0 ) );
         assertTrue( table.has( 1, SIZE ) );
+        assertFalse( table.has( null, null ) );
 
-        assertTrue( table.has( 1, 0, true ) );
-        assertTrue( table.has( 1, 0, false ) );
-        assertFalse( table.has( 1, -1, false ) );
-
-        assertTrue( table.has( 1, SIZE, true ) );
-        assertTrue( table.has( 1, SIZE, false ) );
-        assertTrue( table.has( 1, SIZE, true ) );
-        assertTrue( table.has( 1, SIZE+1, false ) );
-        assertFalse( table.has( 1, SIZE+1, true ) );
+        assertTrue( table.hasGreaterOrEqual( 1, 0 ) );
+        assertTrue( table.hasLessOrEqual( 1, 0 ) );
+        assertFalse( table.hasLessOrEqual( 1, -1 ) );
+        assertFalse( table.hasGreaterOrEqual( null, null ) );
+        assertFalse( table.hasLessOrEqual( null, null ) );
+
+        assertTrue( table.hasGreaterOrEqual( 1, SIZE ) );
+        assertTrue( table.hasLessOrEqual( 1, SIZE ) );
+        assertTrue( table.hasGreaterOrEqual( 1, SIZE ) );
+        assertTrue( table.hasLessOrEqual( 1, SIZE + 1 ) );
+        assertFalse( table.hasGreaterOrEqual( 1, SIZE + 1 ) );
         assertFalse( table.has( 1, SIZE+1 ) );
         
         table.remove( 1 );
 
-        
-        
         // now do not add duplicates and check has( key, boolean )
         for ( int ii = 0; ii < SIZE; ii++ )
         {
@@ -247,20 +265,20 @@
         }
         
         assertFalse( table.has( -1 ) );
-        assertTrue( table.has( -1 , true ) );
-        assertFalse( table.has( -1 , false ) );
+        assertTrue( table.hasGreaterOrEqual( -1 ) );
+        assertFalse( table.hasLessOrEqual( -1 ) );
         
         assertTrue( table.has( 0 ) );
-        assertTrue( table.has( 0 , true ) );
-        assertTrue( table.has( 0 , false ) );
+        assertTrue( table.hasGreaterOrEqual( 0 ) );
+        assertTrue( table.hasLessOrEqual( 0 ) );
         
-        assertTrue( table.has( SIZE-1 ) );
-        assertTrue( table.has( SIZE-1, true ) );
-        assertTrue( table.has( SIZE-1, false ) );
+        assertTrue( table.has( SIZE - 1 ) );
+        assertTrue( table.hasGreaterOrEqual( SIZE - 1 ) );
+        assertTrue( table.hasLessOrEqual( SIZE - 1 ) );
         
         assertFalse( table.has( SIZE ) );
-        assertFalse( table.has( SIZE, true ) );
-        assertTrue( table.has( SIZE, false ) );
+        assertFalse( table.hasGreaterOrEqual( SIZE ) );
+        assertTrue( table.hasLessOrEqual( SIZE ) );
     }
 
     
@@ -322,10 +340,10 @@
         
         table.put( 1, SIZE+1 );
         assertEquals( SIZE+2, table.count() );
-        
+
+        assertEquals( 0, ( int ) table.get( 1 ) );
         
         // now start removing and see what happens 
-
         table.remove( 1, SIZE+1 );
         assertFalse( table.has( 1, SIZE+1 ) );
         assertEquals( SIZE+1, table.count() );



Mime
View raw message