Hey guys. It would be very helpful if you have any...
# android
a
Hey guys. It would be very helpful if you have any idea on this: I have a text file with a long list of strings (12 thousand strings). Would it make sense for me to define a fixed list to use this in my project? Is it better to search through text or use a fixed data structure?
😶 2
r
I would say that depends entirely on how often you would expect to have to search through the whole thing. If not frequently you could search as you're buffering the file, if frequently you could keep the whole thing in memory, which if one line is 100 characters and one character is 2 bytes is 2.4 megabytes for 12 thousand lines. Could also of course keep the whole thing in memory for a while after doing a search in case a second one happens soon after.
To answer your first question: I would not put 12 thousand lines directly in source code. I would be curious to find out how it would affect your build, if the compiler can even process it, but you would still end up with the same overhead (~2.4 megabytes) and no way to clean up the memory again afterwards!
❤️ 1
1
g
search through text or use a fixed data structure
It very depends on how you want to search. Also I would recommend sqlite, it’s easy to include in the project, has high performance for simple text search
1
❤️ 1
a
It’s not allowed to create a list with the size I want 😄 So I added it to asset folder as text and read from there.
😃 1
Thank you for your answers mates…
🙇‍♂️ 1