[jboss-svn-commits] JBL Code SVN: r6678 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Oct 7 11:14:47 EDT 2006


Author: mark.proctor at jboss.com
Date: 2006-10-07 11:14:45 -0400 (Sat, 07 Oct 2006)
New Revision: 6678

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
Log:
JBRULES-498 Optimised HashMap implementations
-Fixed iterator, it uses while looping now instead of recursive, which was upsetting java for really big tables.

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java	2006-10-07 14:01:50 UTC (rev 6677)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java	2006-10-07 15:14:45 UTC (rev 6678)
@@ -21,7 +21,7 @@
     protected Entry[]          table;
 
     
-    private HashTableIterator iterator;
+    private HashTableIterator iterator;   
     
     public AbstractHashTable() {
         this( 16,
@@ -40,6 +40,7 @@
         if ( this.iterator == null ) {
             this.iterator = new HashTableIterator( this );            
         }
+        
         this.iterator.reset();
         return this.iterator;
     }    
@@ -194,16 +195,14 @@
          */
         public Entry next() {            
             if (  this.entry == null ) {
-                row++;
-                if ( row == length ) {
-                    return null;
-                }
-                this.entry = this.table[row];
-                // We have to do this recursively as we may have sparsely populated tables and 
-                // we need to recurse till we either reach a populated row or the end of the table
-                if ( this.entry == null ) {
-                    this.entry = next();
-                }
+                // keep skipping rows until we come to the end, or find one that is populated
+                while  ( this.entry ==  null ) {
+                    row++;
+                    if ( row == length ) {
+                        return null;
+                    }
+                    this.entry = this.table[row];                    
+                }                
             } else {
                 this.entry = this.entry.getNext();
                 if ( this.entry == null ) {




More information about the jboss-svn-commits mailing list