summaryrefslogtreecommitdiff
path: root/core/java/android/util/SparseArray.java
diff options
context:
space:
mode:
authorWinson <chiuwinson@google.com>2021-01-11 17:06:18 -0800
committerWinson <chiuwinson@google.com>2021-01-12 07:59:07 -0800
commit590e9ffb4cb6f1b065ef943030a01e11ddce6f66 (patch)
tree79ab36129b4d90c15d882a781df1652b056f927f /core/java/android/util/SparseArray.java
parent565151c5641e737674037237ccfbf556a95f1454 (diff)
Add SparseArray#set for Kotlin index= operator
Just an alias for put to allow `array[index] = value` syntax in Kotlin. Bug: 163565712 Test: manual, used in tests for separate feature Change-Id: Ie9e17b8f4d16a52f4dc213e1ada8d61fce9eedaf
Diffstat (limited to 'core/java/android/util/SparseArray.java')
-rw-r--r--core/java/android/util/SparseArray.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java
index dae760f989f6..86120d1e650c 100644
--- a/core/java/android/util/SparseArray.java
+++ b/core/java/android/util/SparseArray.java
@@ -241,6 +241,14 @@ public class SparseArray<E> implements Cloneable {
}
/**
+ * Alias for {@link #put(int, Object)} to support Kotlin [index]= operator.
+ * @see #put(int, Object)
+ */
+ public void set(int key, E value) {
+ put(key, value);
+ }
+
+ /**
* Adds a mapping from the specified key to the specified value,
* replacing the previous mapping from the specified key if there
* was one.