Author: jmannix
Date: Fri Apr  5 20:42:12 2013
New Revision: 1465122

URL: http://svn.apache.org/r1465122
Log:
Fixes MAHOUT-1186 (see also https://reviews.apache.org/r/10311 )

Modified:
    
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
    
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
    
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t
    
mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t

Modified: 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
URL: 
http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t?rev=1465122&r1=1465121&r2=1465122&view=diff
==============================================================================
--- 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
 (original)
+++ 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
 Fri Apr  5 20:42:12 2013
@@ -84,8 +84,8 @@ public class Open${keyTypeCap}ObjectHash
   /** Removes all (key,value) associations from the receiver. Implicitly calls 
<tt>trimToSize()</tt>. */
   @Override
   public void clear() {
-    Arrays.fill(state, 0, this.state.length - 1, FREE);
-    Arrays.fill(values, 0, state.length - 1, null); // delta
+    Arrays.fill(state, FREE);
+    Arrays.fill(values, null); // delta
 
     this.distinct = 0;
     this.freeEntries = table.length; // delta

Modified: 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
URL: 
http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t?rev=1465122&r1=1465121&r2=1465122&view=diff
==============================================================================
--- 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
 (original)
+++ 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
 Fri Apr  5 20:42:12 2013
@@ -88,7 +88,7 @@ public class OpenObject${valueTypeCap}Ha
   /** Removes all (key,value) associations from the receiver. Implicitly calls 
<tt>trimToSize()</tt>. */
   @Override
   public void clear() {
-    Arrays.fill(this.state, 0, state.length - 1, FREE);
+    Arrays.fill(this.state, FREE);
     distinct = 0;
     freeEntries = table.length; // delta
     trimToSize();

Modified: 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t
URL: 
http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t?rev=1465122&r1=1465121&r2=1465122&view=diff
==============================================================================
--- 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t
 (original)
+++ 
mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t
 Fri Apr  5 20:42:12 2013
@@ -83,7 +83,7 @@ public class Open${keyTypeCap}HashSet ex
   /** Removes all values associations from the receiver. Implicitly calls 
<tt>trimToSize()</tt>. */
   @Override
   public void clear() {
-    Arrays.fill(this.state, 0, state.length - 1, FREE);
+    Arrays.fill(this.state, FREE);
     distinct = 0;
     freeEntries = table.length; // delta
     trimToSize();

Modified: 
mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t
URL: 
http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t?rev=1465122&r1=1465121&r2=1465122&view=diff
==============================================================================
--- 
mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t
 (original)
+++ 
mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t
 Fri Apr  5 20:42:12 2013
@@ -140,17 +140,20 @@ public class Open${keyTypeCap}ObjectHash
     map.getInternalFactors(capacity, minLoadFactor, maxLoadFactor);
     assertEquals(prime, capacity[0]);
   }
-  
+
   @Test
   public void testClear() {
     Open${keyTypeCap}ObjectHashMap<TestClass> map = new 
Open${keyTypeCap}ObjectHashMap<TestClass>();
-    map.put((${keyType}) 11, item); 
-    assertEquals(1, map.size());
-    map.clear();
-    assertEquals(0, map.size());
-    assertSame(null, map.get((${keyType}) 11));
+    for (int i = 0; i < 100; i++) {
+      map.put((${keyType}) i, item);
+      assertEquals(1, map.size());
+      map.clear();
+      assertEquals(0, map.size());
+      assertFalse("Contains: " + i, map.containsKey((${keyType}) i));
+      assertSame(null, map.get((${keyType}) i));
+    }
   }
-  
+
   @Test
   public void testClone() {
     Open${keyTypeCap}ObjectHashMap<TestClass> map = new 
Open${keyTypeCap}ObjectHashMap<TestClass>();


Reply via email to