JAL-98 use Profile to store consensus, ResidueCount for fast compact
[jalview.git] / src / jalview / ext / android / SparseIntArray.java
index 4ddf776..e286cb4 100644 (file)
@@ -354,13 +354,16 @@ public class SparseIntArray implements Cloneable
    * 
    * @param key
    * @oparam toAdd
+   * @return the new value of the count for the key
    */
-  public void add(int key, int toAdd)
+  public int add(int key, int toAdd)
   {
+    int newValue = toAdd;
     int i = ContainerHelpers.binarySearch(mKeys, mSize, key);
     if (i >= 0)
     {
       mValues[i] += toAdd;
+      newValue = mValues[i];
     }
     else
     {
@@ -370,7 +373,6 @@ public class SparseIntArray implements Cloneable
         int n = idealIntArraySize(mSize + 1);
         int[] nkeys = new int[n];
         int[] nvalues = new int[n];
-        // Log.e("SparseIntArray", "grow " + mKeys.length + " to " + n);
         System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
         System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
         mKeys = nkeys;
@@ -378,7 +380,6 @@ public class SparseIntArray implements Cloneable
       }
       if (mSize - i != 0)
       {
-        // Log.e("SparseIntArray", "move " + (mSize - i));
         System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i);
         System.arraycopy(mValues, i, mValues, i + 1, mSize - i);
       }
@@ -386,5 +387,6 @@ public class SparseIntArray implements Cloneable
       mValues[i] = toAdd;
       mSize++;
     }
+    return newValue;
   }
 }