diff options
| author | Xin Li <delphij@google.com> | 2020-09-10 17:22:01 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-09-10 17:22:01 +0000 |
| commit | 8ac6741e47c76bde065f868ea64d2f04541487b9 (patch) | |
| tree | 1a679458fdbd8d370692d56791e2bf83acee35b5 /core/java/android/util/SparseArray.java | |
| parent | 3de940cc40b1e3fdf8224e18a8308a16768cbfa8 (diff) | |
| parent | c64112eb974e9aa7638aead998f07a868acfb5a7 (diff) | |
Merge "Merge Android R"
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. */ |
