Sub Activity_Create(FirstTime As Boolean)
Dim colorsMap As Map
colorsMap = A2M(Array As Object("red", Colors.Red, "blue", Colors.Blue, "black", Colors.Black))
Log(colorsMap)
End Sub
Sub A2M (arr() As Object) As Map
Dim m As Map
m.Initialize
For i = 0 To arr.Length - 1 Step 2
m.Put(arr(i), arr(i + 1))
Next
Return m
End Sub
How does the internal structure of a map work? When parsing through it by index it is in the order they were added which would indicate an array type structure possibly similar to the original post. A way to pass an array or cast to it would be interesting. Is map a standard Android/JAVA type, and does it use any kind of an indexing system?
Map is not based on an array. Map is based on a custom LinkedHashMap (the customization provides fast index access when the items are accessed in ascending order).
Does that mean it is a one-directional linked list and internally it just stores a reference to the last accessed object in the list? So, if you access items 1-100 it keeps a reference to item 100 and if you access 101 it is quick, but then accessing 50 it has to go back through 1-49?
Also, would this apply to reading by key as well? So, if you read by key and it happens to be index 100 then you read index 101 or the key to index 101 would it read it quicker?
Maps (or hashtables) provide quick access based on the key ~O(1).
GetKeyAt and GetValueAt were added to make it simple to iterate over all the entries.
Fetching items in random order based on the index will be slower. You should use a different data structure for such purpose (for large datasets).