summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-03-29 23:25:07 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-03-29 23:25:07 +0000
commit55e9d98d990f7a015d4c10f5e5a92ae131637073 (patch)
tree697f952f046e98cdf7f7db2e4d271de3af8b4253 /core
parent557ec55641d73db126db0c8e94ec70409814a7c1 (diff)
parent58aff7debfdab8ca99dd6bfcfa0c7bebdf2d303b (diff)
downloadframeworks_base-55e9d98d990f7a015d4c10f5e5a92ae131637073.zip
frameworks_base-55e9d98d990f7a015d4c10f5e5a92ae131637073.tar.gz
frameworks_base-55e9d98d990f7a015d4c10f5e5a92ae131637073.tar.bz2
Merge "Clarify the documentation of SparseArray.indexOfValue."
Diffstat (limited to 'core')
-rw-r--r--core/java/android/util/SparseArray.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java
index 366abd3..7e8fee5 100644
--- a/core/java/android/util/SparseArray.java
+++ b/core/java/android/util/SparseArray.java
@@ -118,7 +118,7 @@ public class SparseArray<E> implements Cloneable {
mGarbage = true;
}
}
-
+
private void gc() {
// Log.e("SparseArray", "gc start with " + mSize);
@@ -214,7 +214,7 @@ public class SparseArray<E> implements Cloneable {
/**
* 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
- * SparseArray stores.
+ * SparseArray stores.
*/
public int keyAt(int index) {
if (mGarbage) {
@@ -223,11 +223,11 @@ public class SparseArray<E> implements Cloneable {
return mKeys[index];
}
-
+
/**
* Given an index in the range <code>0...size()-1</code>, returns
* the value from the <code>index</code>th key-value mapping that this
- * SparseArray stores.
+ * SparseArray stores.
*/
@SuppressWarnings("unchecked")
public E valueAt(int index) {
@@ -241,7 +241,7 @@ public class SparseArray<E> 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
- * SparseArray stores.
+ * SparseArray stores.
*/
public void setValueAt(int index, E value) {
if (mGarbage) {
@@ -250,7 +250,7 @@ public class SparseArray<E> implements Cloneable {
mValues[index] = value;
}
-
+
/**
* Returns the index for which {@link #keyAt} would return the
* specified key, or a negative number if the specified
@@ -268,9 +268,11 @@ public class SparseArray<E> implements Cloneable {
* Returns an index for which {@link #valueAt} would return the
* specified key, or a negative number if no keys map to the
* specified value.
- * Beware that this is a linear search, unlike lookups by key,
+ * <p>Beware that this is a linear search, unlike lookups by key,
* and that multiple keys can map to the same value and this will
* find only one of them.
+ * <p>Note also that unlike most collections' {@code indexOf} methods,
+ * this method compares values using {@code ==} rather than {@code equals}.
*/
public int indexOfValue(E value) {
if (mGarbage) {
@@ -332,7 +334,7 @@ public class SparseArray<E> implements Cloneable {
mValues[pos] = value;
mSize = pos + 1;
}
-
+
private static int binarySearch(int[] a, int start, int len, int key) {
int high = start + len, low = start - 1, guess;