And you have to load them and display them when a person searches through the database...
You have to make it load and search as fast as possible, what method would you use?
The database looks like this:
John Edward III
Prince Henry The Awesome
Gan Is Made Of Epic Sauce
MyParents .Hate Me
Blablabla GaGa RaRa Oh LaLa
And there's 30,000+ names, each name on a separate line.
Search specifications:
Every word typed in the search box has to be partially matched with every word of every name.
If this is in the search box: "Jo Ed"
It will display this: "John Edward III"
If this is in the search box: "E"
It will display this:
"John Edward III
Gan Is Made Of Epic Sauce"
My first attempt at making this involved loading each name in an array and when searching, do string comparisons to every word in every name.
Loading the list of names was fast. Searching through them was as slow as me doing math homework.
My second attempt involved having 26 arrays, each for a letter of the alphabet. I would chop up the names and place each name keyword in an array that symbolized the first letter in the keyword.
Loading was fast, and searching was fairly decent.
My latest attempt involved me trying to put to use some of my knowledge from my college courses. I decided to chop all names into keywords, each keyword was linked to an array that connected to every name that contained that keyword, and I sorted all keywords into an array using a binary sort so I could quickly and efficiently search through by using a binary search algorithm.
Well, loading was slow(4 seconds), but searching wasn't too bad. Still a noticeable hiccup.
My idea, is to use the same method as attempt 3. Except I make a keyword not link to multiple names and have multiple of the same keywords except they each link to a unique name. Then I use binary sort to sort them, and binary search to pull them out. I have a feeling this might be faster in both loading and retrieving.
What methods would you guys use?
(BTW I'm tryin to save on ram and if searching is super fast, I could have loading done asynchronously in the background)