Hey, so, I'm working on a word game for Android and I'm currently trying to optimize my word validation code.
There are something like 270,000 words in the English language and I need to be able to take a user-inputted word and confirm it is in this list very quickly. My goal is under 50ms.
I've written a structure that indexes this list first by number of letters, then by first letter, then by every fiftieth word.
My problem is that after I do this to get the number of bytes to skip in the appropriate word list text file, I call skip(int bytes) on my BufferedReader. Using the Android tracer, I can see that this call takes up 99.7% of the time spent validating a word - up to about 2 seconds in a worst case search. I figure this method is implemented by calling skip(), <bytes> times.
So I am looking for a way to skip into an asset stream in constant time, like simply moving the read pointer by a specified number of bytes without actually reading.
Is this even possible, or should I write a script that divides my word lists up into very small files with 50-100 words each?
Thanks.
There are something like 270,000 words in the English language and I need to be able to take a user-inputted word and confirm it is in this list very quickly. My goal is under 50ms.
I've written a structure that indexes this list first by number of letters, then by first letter, then by every fiftieth word.
My problem is that after I do this to get the number of bytes to skip in the appropriate word list text file, I call skip(int bytes) on my BufferedReader. Using the Android tracer, I can see that this call takes up 99.7% of the time spent validating a word - up to about 2 seconds in a worst case search. I figure this method is implemented by calling skip(), <bytes> times.
So I am looking for a way to skip into an asset stream in constant time, like simply moving the read pointer by a specified number of bytes without actually reading.
Is this even possible, or should I write a script that divides my word lists up into very small files with 50-100 words each?
Thanks.