diff options
Diffstat (limited to 'core/java/android/util/SparseDoubleArray.java')
| -rw-r--r-- | core/java/android/util/SparseDoubleArray.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/java/android/util/SparseDoubleArray.java b/core/java/android/util/SparseDoubleArray.java index e8d96d8e26e4..cb51f7ac13b7 100644 --- a/core/java/android/util/SparseDoubleArray.java +++ b/core/java/android/util/SparseDoubleArray.java @@ -124,6 +124,15 @@ public class SparseDoubleArray implements Cloneable { } /** + * Returns the index for which {@link #keyAt} would return the + * specified key, or a negative number if the specified + * key is not mapped. + */ + public int indexOfKey(int key) { + return mValues.indexOfKey(key); + } + + /** * Given an index in the range <code>0...size()-1</code>, returns * the key from the <code>index</code>th key-value mapping that this * SparseDoubleArray stores. @@ -146,6 +155,20 @@ public class SparseDoubleArray implements Cloneable { } /** + * Given an index in the range <code>0...size()-1</code>, sets a new + * value for the <code>index</code>th key-value mapping that this + * SparseDoubleArray stores. + * + * <p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined for + * apps targeting {@link android.os.Build.VERSION_CODES#P} and earlier, and an + * {@link ArrayIndexOutOfBoundsException} is thrown for apps targeting + * {@link android.os.Build.VERSION_CODES#Q} and later.</p> + */ + public void setValueAt(int index, double value) { + mValues.setValueAt(index, Double.doubleToRawLongBits(value)); + } + + /** * Removes all key-value mappings from this SparseDoubleArray. */ public void clear() { |
