summaryrefslogtreecommitdiff
path: root/core/java/android/util/MapCollections.java
Commit message (Collapse)AuthorAgeFilesLines
* Add @Nullable annotation to the parameter of Object.equals() methods.Roman Kalukiewicz2020-10-151-2/+4
| | | | | | | | | | | | | | | | | | Those annotations could be inferred by some tools (like Kotlin), but the https://checkerframework.org/ doesn't check inherited annotations complaining about all equals() invocations that get nullable argument. The change was generated by running find . -name \*.java | xargs sed -i 's/public boolean equals(Object /public boolean equals(@Nullable Object /' in the frameworks/base directory and by automatically adding and formatting required imports if needed. No manual edits. Bug: 170883422 Test: Annotation change only. Should have not impact. Exempt-From-Owner-Approval: Mechanical change not specific to any component. Change-Id: I5eedb571c9d78862115dfdc5dae1cf2a35343580
* Remove uses of libcore.util.Objects.hashCode / equals.Narayan Kamath2018-02-191-5/+4
| | | | | | | Use public API in java.util.Objects instead. Test: make Change-Id: I413280f254743a2efa2640a2194693aeb5980605
* Don't allow MapCollections to iterate past the end.Tobias Thierer2017-03-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Prior to this CL, MapCollections such as ArrayMap's entrySet, keySet and values, exhibited unusual Iterator behavior: - instead of throwing NoSuchElementException once the end of the Collection was reached, Iterator.next() instead returned a null key / a null value / an entry with a null key and value. - however, remove() removed the last actual element of the Collection; successive calls of next(), remove() would result in successive elements being removed, in reverse iteration order. - Once the Collection had been cleared through calls to remove(), ArrayIndexOutOfBoundsException was thrown from iterator.next() (for keySet and values) or from iterator.remove (for entrySet). This CL fixes those Collections' Iterators to let next() throw NoSuchElementException when hasNext() would have returned false. Since the new behavior was already guaranteed by the Iterator documentation, any app compatibility effect from this CL is both unlikely, and unlikely to be negative. Bug: 19853326 Test: make cts && cts-tradefed run cts -m CtsUtilTestCases Change-Id: Ie3f0594f434dd5625799791829bd94fbaef94906
* Fix off-by-one issue when removing from IteratorAdam Lesinski2013-11-011-1/+1
| | | | | | | | | MapCollections' iterator removes the preceding element which causes IndexOutOfBoundsExceptions to be thrown when removing the first element while iterating. bug:11477476 Change-Id: Ifc8fcf0ca1651e759f3b2ab8356404564e9f7d0b
* Fix issue #10491028: iabv2 test apps that contain subscription SKUs...Dianne Hackborn2013-09-051-2/+2
| | | | | | | | ...crash on launch You got some values in my keys! Change-Id: I2636c72843e0c0900ccdd9acba771c1b61e70b39
* Fix issue #10115327: MapCollections need to implement equalsDianne Hackborn2013-07-311-5/+68
| | | | Change-Id: I8e7b6dd092442f3870aa1a36bd2a7cd974177146
* New ArrayMap class.Dianne Hackborn2013-05-241-0/+496
This is a new kind of key/value mapping that stores its data as an array, so it doesn't need to create an extra Entry object for every mapping placed in to it. It is also optimized to reduce memory overhead in other ways, by keeping the base object small, being fairly aggressive about keeping the array data structures small, etc. There are some unit and performance tests dropped in to some random places; they will need to be put somewhere else once I decided what we are going to do with this for the next release (for example if we make it public the unit tests should go in to CTS). Switch IntentResolver to using ArrayMap instead of HashMap. Also get rid of a bunch of duplicate implementations of binarySearch, and add an optimization to the various sparse arrays where you can supply an explicit 0 capacity to prevent it from doing an initial array allocation; use this new optimization in a few places where it makes sense. Change-Id: I01ef2764680f8ae49938e2a2ed40dc01606a056b