summaryrefslogtreecommitdiff
path: root/core/java/android/util/SparseBooleanArray.java
diff options
context:
space:
mode:
authorFlavio Lerda <flerda@google.com>2013-09-12 11:49:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-12 11:49:29 +0000
commitb25cfdf1ece9163292e2b4c86910fe07b14c0afa (patch)
tree4bdc45af5a1854d316473d0724931803a5006717 /core/java/android/util/SparseBooleanArray.java
parent737d2c0b92b69d9069de6fe0e2785676b9a10d78 (diff)
parent5771302ca13c31cb85f17bc58da8f6f8227c9b85 (diff)
Merge "Document the order of values returned by keyAt()." into klp-dev
Diffstat (limited to 'core/java/android/util/SparseBooleanArray.java')
-rw-r--r--core/java/android/util/SparseBooleanArray.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/util/SparseBooleanArray.java b/core/java/android/util/SparseBooleanArray.java
index da196d78161d..68487e391710 100644
--- a/core/java/android/util/SparseBooleanArray.java
+++ b/core/java/android/util/SparseBooleanArray.java
@@ -33,6 +33,12 @@ import com.android.internal.util.ArrayUtils;
* HashMap, since lookups require a binary search and adds and removes require inserting
* and deleting entries in the array. For containers holding up to hundreds of items,
* the performance difference is not significant, less than 50%.</p>
+ *
+ * <p>It is possible to iterate over the items in this container using
+ * {@link #keyAt(int)} and {@link #valueAt(int)}. Iterating over the keys using
+ * <code>keyAt(int)</code> with ascending values of the index will return the
+ * keys in ascending order, or the values corresponding to the keys in ascending
+ * order in the case of <code>valueAt(int)<code>.</p>
*/
public class SparseBooleanArray implements Cloneable {
/**
@@ -159,16 +165,27 @@ public class SparseBooleanArray 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
- * SparseBooleanArray stores.
+ * SparseBooleanArray stores.
+ *
+ * <p>The keys corresponding to indices in ascending order are guaranteed to
+ * be in ascending order, e.g., <code>keyAt(0)</code> will return the
+ * smallest key and <code>keyAt(size()-1)</code> will return the largest
+ * key.</p>
*/
public int keyAt(int index) {
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
- * SparseBooleanArray stores.
+ * SparseBooleanArray stores.
+ *
+ * <p>The values corresponding to indices in ascending order are guaranteed
+ * to be associated with keys in ascending order, e.g.,
+ * <code>valueAt(0)</code> will return the value associated with the
+ * smallest key and <code>valueAt(size()-1)</code> will return the value
+ * associated with the largest key.</p>
*/
public boolean valueAt(int index) {
return mValues[index];