Android Question Reverse map items

Andrei E

Member
Licensed User
Longtime User
How to properly fix this reverse function
B4X:
Sub Reverse(m As Map, p As String)
    For i = 0 To m.Size - 1
        Dim k As Object = m.GetKeyAt(i)
        Dim v As Object = m.GetValueAt(i)
        If v Is Map Then
            Reverse(m.Get(k), "/" & k)
        Else
            Log(p & "/" & k)
        End If
    Next
End Sub
Usage example:
B4X:
Dim m As Map
m.Initialize
m.Put(1, "abc")
m.Put(2, CreateMap(1 : "abc", 2 : "def"))
m.Put(3, CreateMap(1 : "abc", 2 : "def", 3 : CreateMap(1 : "abc", 2: "def")))
Reverse(m, "")
The result should be like this:
/1
/2/1
/2/2
/3/1
/3/2
/3/3/1
/3/3/2
but it's incoorect
/1
/2/1
/2/2
/3/1
/3/2
/3/1
/3/2
 

Andrei E

Member
Licensed User
Longtime User
Hi Erel
I want to get proprly path (not a item sort) of map items
Like a reverse search in the filesystem where the "Map" is a folder name and the filename is a string key of the map
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…