mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robina...@apache.org
Subject svn commit: r907203 - in /lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math: map/OpenKeyTypeObjectHashMap.java.t map/OpenKeyTypeValueTypeHashMap.java.t map/OpenObjectValueTypeHashMap.java.t set/OpenKeyTypeHashSet.java.t
Date Sat, 06 Feb 2010 11:50:38 GMT
Author: robinanil
Date: Sat Feb  6 11:50:37 2010
New Revision: 907203

URL: http://svn.apache.org/viewvc?rev=907203&view=rev
Log:
Small changes: Redundant code removed and some tweaks

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

Modified: lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t?rev=907203&r1=907202&r2=907203&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
(original)
+++ lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
Sat Feb  6 11:50:37 2010
@@ -197,7 +197,7 @@
    */
   @Override
   public T get(${keyType} key) {
-    int i = indexOfKey(key);
+    final int i = indexOfKey(key);
     if (i < 0) {
       return null;
     } //not contained
@@ -212,11 +212,9 @@
    *         slot index.
    */
   protected int indexOfInsertion(${keyType} key) {
-    ${keyType}[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
+    final int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -226,7 +224,7 @@
 
     // stop if we find a removed or free slot, or if we find the key itself
     // do NOT skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] == FULL && tab[i] != key) {
+    while (state[i] == FULL && table[i] != key) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -234,25 +232,25 @@
       }
     }
 
-    if (stat[i] == REMOVED) {
+    if (state[i] == REMOVED) {
       // stop if we find a free slot, or if we find the key itself.
       // do skip over removed slots (yes, open addressing is like that...)
       // assertion: there is at least one FREE slot.
-      int j = i;
-      while (stat[i] != FREE && (stat[i] == REMOVED || tab[i] != key)) {
+      final int j = i;
+      while (state[i] != FREE && (state[i] == REMOVED || table[i] != key)) {
         i -= decrement;
         //hashCollisions++;
         if (i < 0) {
           i += length;
         }
       }
-      if (stat[i] == FREE) {
+      if (state[i] == FREE) {
         i = j;
       }
     }
 
 
-    if (stat[i] == FULL) {
+    if (state[i] == FULL) {
       // key already contained at slot i.
       // return a negative number identifying the slot.
       return -i - 1;
@@ -267,11 +265,9 @@
    * @return the index where the key is contained in the receiver, returns -1 if the key
was not found.
    */
   protected int indexOfKey(${keyType} key) {
-    ${keyType}[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
+    final int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -281,7 +277,7 @@
 
     // stop if we find a free slot, or if we find the key itself.
     // do skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] != FREE && (stat[i] == REMOVED || tab[i] != key)) {
+    while (state[i] != FREE && (state[i] == REMOVED || table[i] != key)) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -289,7 +285,7 @@
       }
     }
 
-    if (stat[i] == FREE) {
+    if (state[i] == FREE) {
       return -1;
     } // not found
     return i; //found, return index where key is contained
@@ -325,13 +321,10 @@
     list.setSize(distinct);
     ${keyType}[] elements = list.elements();
 
-    ${keyType}[] tab = table;
-    byte[] stat = state;
-
     int j = 0;
-    for (int i = tab.length; i-- > 0;) {
-      if (stat[i] == FULL) {
-        elements[j++] = tab[i];
+    for (int i = table.length; i-- > 0;) {
+      if (state[i] == FULL) {
+        elements[j++] = table[i];
       }
     }
   }
@@ -422,25 +415,22 @@
     T[] oldValues = values;
     byte[] oldState = state;
 
-    ${keyType}[] newTable = new ${keyType}[newCapacity];
-    T[] newValues = (T[]) new Object[newCapacity];
-    byte[] newState = new byte[newCapacity];
+    this.table = new ${keyType}[newCapacity];
+    this.values = (T[]) new Object[newCapacity];
+    this.state = new byte[newCapacity];
 
     this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);
     this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);
 
-    this.table = newTable;
-    this.values = newValues;
-    this.state = newState;
     this.freeEntries = newCapacity - this.distinct; // delta
 
     for (int i = oldCapacity; i-- > 0;) {
       if (oldState[i] == FULL) {
         ${keyType} element = oldTable[i];
         int index = indexOfInsertion(element);
-        newTable[index] = element;
-        newValues[index] = oldValues[i];
-        newState[index] = FULL;
+        this.table[index] = element;
+        this.values[index] = oldValues[i];
+        this.state[index] = FULL;
       }
     }
   }
@@ -539,12 +529,9 @@
   public void values(List<T> list) {
     list.clear();
 
-    T[] val = values;
-    byte[] stat = state;
-
-    for (int i = stat.length; i-- > 0;) {
-      if (stat[i] == FULL) {
-        list.add(val[i]);
+    for (int i = state.length; i-- > 0;) {
+      if (state[i] == FULL) {
+        list.add(values[i]);
       }
     }
   }
@@ -555,7 +542,7 @@
    * @param minLoadFactor
    * @param maxLoadFactor
    */
-  void getInternalFactors(int[] capacity, 
+  protected void getInternalFactors(int[] capacity, 
       double[] minLoadFactor, 
       double[] maxLoadFactor) {
     capacity[0] = table.length;

Modified: lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeValueTypeHashMap.java.t
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeValueTypeHashMap.java.t?rev=907203&r1=907202&r2=907203&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeValueTypeHashMap.java.t
(original)
+++ lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeValueTypeHashMap.java.t
Sat Feb  6 11:50:37 2010
@@ -207,7 +207,7 @@
    */
   @Override
   public ${valueType} get(${keyType} key) {
-    int i = indexOfKey(key);
+    final int i = indexOfKey(key);
     if (i < 0) {
       return 0;
     } //not contained
@@ -222,11 +222,9 @@
    *         slot index.
    */
   protected int indexOfInsertion(${keyType} key) {
-    ${keyType}[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
+    final int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -236,7 +234,7 @@
 
     // stop if we find a removed or free slot, or if we find the key itself
     // do NOT skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] == FULL && tab[i] != key) {
+    while (state[i] == FULL && table[i] != key) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -244,25 +242,25 @@
       }
     }
 
-    if (stat[i] == REMOVED) {
+    if (state[i] == REMOVED) {
       // stop if we find a free slot, or if we find the key itself.
       // do skip over removed slots (yes, open addressing is like that...)
       // assertion: there is at least one FREE slot.
-      int j = i;
-      while (stat[i] != FREE && (stat[i] == REMOVED || tab[i] != key)) {
+      final int j = i;
+      while (state[i] != FREE && (state[i] == REMOVED || table[i] != key)) {
         i -= decrement;
         //hashCollisions++;
         if (i < 0) {
           i += length;
         }
       }
-      if (stat[i] == FREE) {
+      if (state[i] == FREE) {
         i = j;
       }
     }
 
 
-    if (stat[i] == FULL) {
+    if (state[i] == FULL) {
       // key already contained at slot i.
       // return a negative number identifying the slot.
       return -i - 1;
@@ -277,11 +275,9 @@
    * @return the index where the key is contained in the receiver, returns -1 if the key
was not found.
    */
   protected int indexOfKey(${keyType} key) {
-    ${keyType}[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
+    final int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -291,7 +287,7 @@
 
     // stop if we find a free slot, or if we find the key itself.
     // do skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] != FREE && (stat[i] == REMOVED || tab[i] != key)) {
+    while (state[i] != FREE && (state[i] == REMOVED || table[i] != key)) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -299,7 +295,7 @@
       }
     }
 
-    if (stat[i] == FREE) {
+    if (state[i] == FREE) {
       return -1;
     } // not found
     return i; //found, return index where key is contained
@@ -336,13 +332,10 @@
     list.setSize(distinct);
     ${keyType} [] elements = list.elements();
 
-    ${keyType} [] tab = table;
-    byte[] stat = state;
-
     int j = 0;
-    for (int i = tab.length; i-- > 0;) {
-      if (stat[i] == FULL) {
-        elements[j++] = tab[i];
+    for (int i = table.length; i-- > 0;) {
+      if (state[i] == FULL) {
+        elements[j++] = table[i];
       }
     }
   }
@@ -445,25 +438,22 @@
     ${valueType}[] oldValues = values;
     byte[] oldState = state;
 
-    ${keyType}[] newTable = new ${keyType}[newCapacity];
-    ${valueType}[] newValues = new ${valueType}[newCapacity];
-    byte[] newState = new byte[newCapacity];
+    this.table = new ${keyType}[newCapacity];
+    this.values = new ${valueType}[newCapacity];
+    this.state = new byte[newCapacity];
 
     this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);
     this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);
 
-    this.table = newTable;
-    this.values = newValues;
-    this.state = newState;
     this.freeEntries = newCapacity - this.distinct; // delta
 
     for (int i = oldCapacity; i-- > 0;) {
       if (oldState[i] == FULL) {
         ${keyType} element = oldTable[i];
         int index = indexOfInsertion(element);
-        newTable[index] = element;
-        newValues[index] = oldValues[i];
-        newState[index] = FULL;
+        this.table[index] = element;
+        this.values[index] = oldValues[i];
+        this.state[index] = FULL;
       }
     }
   }
@@ -563,13 +553,10 @@
     list.setSize(distinct);
     ${valueType}[] elements = list.elements();
 
-    ${valueType}[] val = values;
-    byte[] stat = state;
-
     int j = 0;
-    for (int i = stat.length; i-- > 0;) {
-      if (stat[i] == FULL) {
-        elements[j++] = val[i];
+    for (int i = state.length; i-- > 0;) {
+      if (state[i] == FULL) {
+        elements[j++] = values[i];
       }
     }
   }
@@ -580,7 +567,7 @@
    * @param minLoadFactor
    * @param maxLoadFactor
    */
-  void getInternalFactors(int[] capacity, 
+  protected void getInternalFactors(int[] capacity, 
       double[] minLoadFactor, 
       double[] maxLoadFactor) {
     capacity[0] = table.length;

Modified: lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t?rev=907203&r1=907202&r2=907203&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
(original)
+++ lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
Sat Feb  6 11:50:37 2010
@@ -201,7 +201,7 @@
    */
   @Override
   public ${valueType} get(T key) {
-    int i = indexOfKey(key);
+    final int i = indexOfKey(key);
     if (i < 0) {
       return 0;
     } //not contained
@@ -216,11 +216,9 @@
    *         slot index.
    */
   protected int indexOfInsertion(T key) {
-    Object[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = key.hashCode() & 0x7FFFFFFF;
+    final int hash = key.hashCode() & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -230,7 +228,7 @@
 
     // stop if we find a removed or free slot, or if we find the key itself
     // do NOT skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] == FULL && !equalsMindTheNull(tab[i], key)) {
+    while (state[i] == FULL && !equalsMindTheNull(table[i], key)) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -238,25 +236,25 @@
       }
     }
 
-    if (stat[i] == REMOVED) {
+    if (state[i] == REMOVED) {
       // stop if we find a free slot, or if we find the key itself.
       // do skip over removed slots (yes, open addressing is like that...)
       // assertion: there is at least one FREE slot.
-      int j = i;
-      while (stat[i] != FREE && (stat[i] == REMOVED || !equalsMindTheNull(tab[i],
key))) {
+      final int j = i;
+      while (state[i] != FREE && (state[i] == REMOVED || !equalsMindTheNull(table[i],
key))) {
         i -= decrement;
         //hashCollisions++;
         if (i < 0) {
           i += length;
         }
       }
-      if (stat[i] == FREE) {
+      if (state[i] == FREE) {
         i = j;
       }
     }
 
 
-    if (stat[i] == FULL) {
+    if (state[i] == FULL) {
       // key already contained at slot i.
       // return a negative number identifying the slot.
       return -i - 1;
@@ -271,11 +269,9 @@
    * @return the index where the key is contained in the receiver, returns -1 if the key
was not found.
    */
   protected int indexOfKey(T key) {
-    Object[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = key.hashCode() & 0x7FFFFFFF;
+    final int hash = key.hashCode() & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -285,7 +281,7 @@
 
     // stop if we find a free slot, or if we find the key itself.
     // do skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] != FREE && (stat[i] == REMOVED || !equalsMindTheNull(tab[i], key)))
{
+    while (state[i] != FREE && (state[i] == REMOVED || !equalsMindTheNull(table[i],
key))) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -293,7 +289,7 @@
       }
     }
 
-    if (stat[i] == FREE) {
+    if (state[i] == FREE) {
       return -1;
     } // not found
     return i; //found, return index where key is contained
@@ -328,14 +324,10 @@
   @SuppressWarnings("unchecked")
   public void keys(List<T> list) {
     list.clear();
-  
-
-    Object [] tab = table;
-    byte[] stat = state;
 
-    for (int i = tab.length; i-- > 0;) {
-      if (stat[i] == FULL) {
-        list.add((T)tab[i]);
+    for (int i = table.length; i-- > 0;) {
+      if (state[i] == FULL) {
+        list.add((T)table[i]);
       }
     }
   }
@@ -439,25 +431,22 @@
     ${valueType}[] oldValues = values;
     byte[] oldState = state;
 
-    Object[] newTable = new Object[newCapacity];
-    ${valueType}[] newValues = new ${valueType}[newCapacity];
-    byte[] newState = new byte[newCapacity];
+    this.table = new Object[newCapacity];
+    this.values = new ${valueType}[newCapacity];
+    this.state = new byte[newCapacity];
 
     this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);
     this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);
 
-    this.table = newTable;
-    this.values = newValues;
-    this.state = newState;
     this.freeEntries = newCapacity - this.distinct; // delta
 
     for (int i = oldCapacity; i-- > 0;) {
       if (oldState[i] == FULL) {
         Object element = oldTable[i];
         int index = indexOfInsertion((T)element);
-        newTable[index] = element;
-        newValues[index] = oldValues[i];
-        newState[index] = FULL;
+        this.table[index] = element;
+        this.values[index] = oldValues[i];
+        this.state[index] = FULL;
       }
     }
   }
@@ -556,13 +545,10 @@
     list.setSize(distinct);
     ${valueType}[] elements = list.elements();
 
-    ${valueType}[] val = values;
-    byte[] stat = state;
-
     int j = 0;
-    for (int i = stat.length; i-- > 0;) {
-      if (stat[i] == FULL) {
-        elements[j++] = val[i];
+    for (int i = state.length; i-- > 0;) {
+      if (state[i] == FULL) {
+        elements[j++] = values[i];
       }
     }
   }
@@ -573,7 +559,7 @@
    * @param minLoadFactor
    * @param maxLoadFactor
    */
-  void getInternalFactors(int[] capacity, 
+  protected void getInternalFactors(int[] capacity, 
       double[] minLoadFactor, 
       double[] maxLoadFactor) {
     capacity[0] = table.length;

Modified: lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t?rev=907203&r1=907202&r2=907203&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t
(original)
+++ lucene/mahout/trunk/math/src/main/java-templates/org/apache/mahout/math/set/OpenKeyTypeHashSet.java.t
Sat Feb  6 11:50:37 2010
@@ -160,11 +160,9 @@
    *         slot index.
    */
   protected int indexOfInsertion(${keyType} key) {
-    ${keyType}[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
+    final int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -174,7 +172,7 @@
 
     // stop if we find a removed or free slot, or if we find the key itself
     // do NOT skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] == FULL && tab[i] != key) {
+    while (state[i] == FULL && table[i] != key) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -182,25 +180,25 @@
       }
     }
 
-    if (stat[i] == REMOVED) {
+    if (state[i] == REMOVED) {
       // stop if we find a free slot, or if we find the key itself.
       // do skip over removed slots (yes, open addressing is like that...)
       // assertion: there is at least one FREE slot.
-      int j = i;
-      while (stat[i] != FREE && (stat[i] == REMOVED || tab[i] != key)) {
+      final int j = i;
+      while (state[i] != FREE && (state[i] == REMOVED || table[i] != key)) {
         i -= decrement;
         //hashCollisions++;
         if (i < 0) {
           i += length;
         }
       }
-      if (stat[i] == FREE) {
+      if (state[i] == FREE) {
         i = j;
       }
     }
 
 
-    if (stat[i] == FULL) {
+    if (state[i] == FULL) {
       // key already contained at slot i.
       // return a negative number identifying the slot.
       return -i - 1;
@@ -215,11 +213,9 @@
    * @return the index where the key is contained in the receiver, returns -1 if the key
was not found.
    */
   protected int indexOfKey(${keyType} key) {
-    ${keyType}[] tab = table;
-    byte[] stat = state;
-    int length = tab.length;
+    final int length = table.length;
 
-    int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
+    final int hash = HashFunctions.hash(key) & 0x7FFFFFFF;
     int i = hash % length;
     int decrement = hash % (length - 2); // double hashing, see http://www.eece.unm.edu/faculty/heileman/hash/node4.html
     //int decrement = (hash / length) % length;
@@ -229,7 +225,7 @@
 
     // stop if we find a free slot, or if we find the key itself.
     // do skip over removed slots (yes, open addressing is like that...)
-    while (stat[i] != FREE && (stat[i] == REMOVED || tab[i] != key)) {
+    while (state[i] != FREE && (state[i] == REMOVED || table[i] != key)) {
       i -= decrement;
       //hashCollisions++;
       if (i < 0) {
@@ -237,7 +233,7 @@
       }
     }
 
-    if (stat[i] == FREE) {
+    if (state[i] == FREE) {
       return -1;
     } // not found
     return i; //found, return index where key is contained
@@ -257,13 +253,10 @@
     list.setSize(distinct);
     ${keyType} [] elements = list.elements();
 
-    ${keyType} [] tab = table;
-    byte[] stat = state;
-
     int j = 0;
-    for (int i = tab.length; i-- > 0;) {
-      if (stat[i] == FULL) {
-        elements[j++] = tab[i];
+    for (int i = table.length; i-- > 0;) {
+      if (state[i] == FULL) {
+        elements[j++] = table[i];
       }
     }
   }
@@ -318,22 +311,20 @@
     ${keyType}[] oldTable = table;
     byte[] oldState = state;
 
-    ${keyType}[] newTable = new ${keyType}[newCapacity];
-    byte[] newState = new byte[newCapacity];
+    this.table = new ${keyType}[newCapacity];
+    this.state = new byte[newCapacity];
 
     this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);
     this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);
 
-    this.table = newTable;
-    this.state = newState;
     this.freeEntries = newCapacity - this.distinct; // delta
 
     for (int i = oldCapacity; i-- > 0;) {
       if (oldState[i] == FULL) {
         ${keyType} element = oldTable[i];
         int index = indexOfInsertion(element);
-        newTable[index] = element;
-        newState[index] = FULL;
+        this.table[index] = element;
+        this.state[index] = FULL;
       }
     }
   }
@@ -423,7 +414,7 @@
    * @param minLoadFactor
    * @param maxLoadFactor
    */
-  void getInternalFactors(int[] capacity, 
+  protected void getInternalFactors(int[] capacity, 
       double[] minLoadFactor, 
       double[] maxLoadFactor) {
     capacity[0] = table.length;



Mime
View raw message