uniplan Active Member Licensed User Longtime User Jan 2, 2018 #1 I created a map by entering the individual elements by ordering the key in alphabetical order. I then saved the map to a file with the File.WriteMap statement. I then reloaded the map with the File.ReadMap statement. Finally I read the first element of the map with the instruction: Code: myMap.GetKeyAt (0) The element I found was not the first one I had inserted. Is there a way to reload the map in the same order I did the insertion? Thanks.
I created a map by entering the individual elements by ordering the key in alphabetical order. I then saved the map to a file with the File.WriteMap statement. I then reloaded the map with the File.ReadMap statement. Finally I read the first element of the map with the instruction: Code: myMap.GetKeyAt (0) The element I found was not the first one I had inserted. Is there a way to reload the map in the same order I did the insertion? Thanks.
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2018 #2 In almost all cases it is a mistake to use Map.GetKeyAt or GetValueAt. You should access the map based on the keys or with a For Each loop. If the order is important then you should probably switch to a List with custom types. You can serialize it with B4XSerializator. You can preserve the map order with File.ReadMap2 or by serializing it with B4XSerializator. Upvote 0
In almost all cases it is a mistake to use Map.GetKeyAt or GetValueAt. You should access the map based on the keys or with a For Each loop. If the order is important then you should probably switch to a List with custom types. You can serialize it with B4XSerializator. You can preserve the map order with File.ReadMap2 or by serializing it with B4XSerializator.
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2018 #3 If you choose to use B4XSerializator then you can use it together with FileToBytes and BytesToFile: https://www.b4x.com/android/forum/threads/70111/#content Upvote 0
If you choose to use B4XSerializator then you can use it together with FileToBytes and BytesToFile: https://www.b4x.com/android/forum/threads/70111/#content