-
Notifications
You must be signed in to change notification settings - Fork 1
List and Map
Daniel Bergløv edited this page Oct 25, 2015
·
1 revision
UtilsLib comes with it's own Map and List classes, named SparseMap
and SparseList
, both of which are built with optimized sorting and garbage collection. They are based on the idea of Android's SparseArray
, only these include two key elements. First of all they implement the Map
and List
interface so that they can be used in conjunction with all other Map
and List
types. Secondly they both implement the Parcelable
feature so that they can be disassembled and reassembled when parsing it though IPC.
When it comes down to speed, these two classes beats SparseArray
, ArrayMap
, HashMap
and ArrayList
. However comparing SparseMap
to ArrayMap
and HashMap
might not be ideal considering that it only uses Interger
as keys like SparseArray
.
Example
List<String> mList = new SparseList<String>();
Map<Integer, String> mMap = new SparseMap<String>();
mList.add("");
mMap.put(10, "");