I'm writing some tests to learn the language.
The case: I want to search for cities from a text file with 8000 cities.
My questions are about style and speed, to discover if there are other better or faster options. In this moment I don't look for any sql solution, just to understand if some commands can be written better.
1) this is very fast. Great:
2) insensitive search in debug mode is slow, in release mode it's fast (i limit however to the first 25 occurancies)
2a) is there any faster method in debug mode ?
2b) is regex faster than
?
3) there's a faster method to add items to tableview1, or there's a library/module better thant tableview ?
Thanks in advance to all. The code is working, good for beginners as me to learn a very simple search in realtime in large list of items.
The case: I want to search for cities from a text file with 8000 cities.
My questions are about style and speed, to discover if there are other better or faster options. In this moment I don't look for any sql solution, just to understand if some commands can be written better.
1) this is very fast. Great:
B4X:
Dim cities As List = File.ReadList(File.DirAssets, "cities.txt")
2) insensitive search in debug mode is slow, in release mode it's fast (i limit however to the first 25 occurancies)
B4X:
stringa=stringa.ToLowerCase
Do While cnt < cntmax
tmpstring=cities.Get(totcnt)
tmpstring=tmpstring.ToLowerCase
If (tmpstring.IndexOf(stringa)>-1 ) Then
TableView1.AddSingleLine(cities.Get(totcnt))
cnt=cnt+1
End If
totcnt=totcnt+1
If totcnt = totcities Then
Exit
End If
Loop
2a) is there any faster method in debug mode ?
2b) is regex faster than
B4X:
tmpstring=cities.Get(totcnt)
tmpstring=tmpstring.ToLowerCase
If (tmpstring.IndexOf(stringa)>-1 ) Then
3) there's a faster method to add items to tableview1, or there's a library/module better thant tableview ?
B4X:
TableView1.clear
do while
TableView1.AddSingleLine(cities.Get(totcnt))
loop
TableView1.ReloadAll
Thanks in advance to all. The code is working, good for beginners as me to learn a very simple search in realtime in large list of items.