Hi there!
I am trying to use a MAP to store objects for which it is from a great importance to keep ordered. The more I am trying, the more I realize maybe it's not what MAPs are about.
In my other topic I can't use WriteMap, ReadMap due to an error but I made a separate app to test things out.
The application runs correctly, everything is okay but the order I get my MsgBox-es is as follows:
- second item
- third item
- first item
I noticed there are m.Put("#Item1", "") commands which do the ordering trick.
But my items are dynamic?
It is more a question if it is possible(and how?) or I should go for another storage option.
By the way, I am recording the "ticks" when the item is added. Maybe it can be used for ordering purposes but anyway it won't happen with the single readMap/readMap2 commands and I will have to order the items myself.
I am trying to use a MAP to store objects for which it is from a great importance to keep ordered. The more I am trying, the more I realize maybe it's not what MAPs are about.
In my other topic I can't use WriteMap, ReadMap due to an error but I made a separate app to test things out.
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim map1 As Map
map1.Initialize
map1.Put("a","first item")
map1.Put("b","second item")
map1.Put("c","third item")
File.WriteMap(File.DirInternal, "storage.txt", map1)
Dim map2 As Map
map2.Initialize
map2.Put("a", "")
map2.Put("b", "")
map2.Put("c", "")
map2 = File.ReadMap2(File.DirInternal, "storage.txt", map2)
For i = 0 To map2.Size - 1
Dim a As String
a = map2.GetValueAt(i)
Msgbox(a, "AAAA")
Next
End Sub
The application runs correctly, everything is okay but the order I get my MsgBox-es is as follows:
- second item
- third item
- first item
I noticed there are m.Put("#Item1", "") commands which do the ordering trick.
But my items are dynamic?
It is more a question if it is possible(and how?) or I should go for another storage option.
By the way, I am recording the "ticks" when the item is added. Maybe it can be used for ordering purposes but anyway it won't happen with the single readMap/readMap2 commands and I will have to order the items myself.
Last edited: