diff options
| author | Xin Li <delphij@google.com> | 2020-09-09 20:21:10 -0700 |
|---|---|---|
| committer | Xin Li <delphij@google.com> | 2020-09-09 20:21:10 -0700 |
| commit | c64112eb974e9aa7638aead998f07a868acfb5a7 (patch) | |
| tree | 503334edcee47bfd9f7a76d987d881992ecae9aa /core/java/android/util/SparseArray.java | |
| parent | 104d2f92b3911576c284ddb0adf78148359883d2 (diff) | |
| parent | 14a6871e432e163533a320516ace97bd67d9c3a0 (diff) | |
Merge Android R
Bug: 168057903
Merged-In: Ice3e441cc9c0df8d0a6acc016bb74375e081bd67
Change-Id: I1d85742f594be2007c99841b290e502b6ede624e
Diffstat (limited to 'core/java/android/util/SparseArray.java')
| -rw-r--r-- | core/java/android/util/SparseArray.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java index 3a0d1f5a6cc8..dae760f989f6 100644 --- a/core/java/android/util/SparseArray.java +++ b/core/java/android/util/SparseArray.java @@ -104,6 +104,17 @@ public class SparseArray<E> implements Cloneable { } /** + * Returns true if the key exists in the array. This is equivalent to + * {@link #indexOfKey(int)} >= 0. + * + * @param key Potential key in the mapping + * @return true if the key is defined in the mapping + */ + public boolean contains(int key) { + return indexOfKey(key) >= 0; + } + + /** * Gets the Object mapped from the specified key, or <code>null</code> * if no such mapping has been made. */ |
