diff options
| author | Kweku Adams <kwekua@google.com> | 2019-11-14 14:59:57 -0800 |
|---|---|---|
| committer | Kweku Adams <kwekua@google.com> | 2019-11-18 17:58:00 -0800 |
| commit | a26ae90b4dfe9397aafa7ab15a4b3cd887ca7585 (patch) | |
| tree | 88546687b1ef84df95ee6101d9780abaf06e3484 /core/java/android/util/SparseArray.java | |
| parent | cefa9e3ef85adf5850c85552071a3af5b433f61c (diff) | |
Extract SparseArrayMap from QuotaController.
This structure can be useful in other parts of the system, so extracting
it and making it more generic makes sense.
Bug: 135764360
Bug: 141645789
Test: atest QuotaControllerTest
Test: atest SparseArrayMapTest
Change-Id: I2aeb3ea53e3dc2ec00667a0a2ccdb112cf562377
Diffstat (limited to 'core/java/android/util/SparseArray.java')
| -rw-r--r-- | core/java/android/util/SparseArray.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java index 0a15db227823..484894f98023 100644 --- a/core/java/android/util/SparseArray.java +++ b/core/java/android/util/SparseArray.java @@ -104,6 +104,14 @@ public class SparseArray<E> implements Cloneable { } /** + * Returns true if the key exists in the array. This is equivalent to + * {@link #indexOfKey(int)} >= 0. + */ + 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. */ |
