I'm working on an app that takes voice input, and matches that input to known items in a manifest.
Each item in the manifest has a list of aliases, so that items with long titles can be matched to shorter names.
For example:
class Product
{
itemname: "Old Stinky's Western Kentucky Big Rig Polish",
aliases: ["old stinky", "other alias"]
}
And then loaded into memory as:
public List<Product> Collection;
Collection.Add(alltheproducts);
And then matched through:
public String isProductOrAlias(String lowertext)
for (Product p: products.Collection) {
if(lowertext.equals(p.name.toLowerCase()))
return p.name;
if(p.aliases != null) {
for (String s: p.aliases) {
if(lowertext.equals(s.toLowerCase()))
return p.name;
}
}
}
This is working great on a test batch of twenty five items in the prototype, but eventually it will need to handle 5,000-10,000 items in as close to real time as possible on a phone.
Core Question:
Assuming I can hold 10,000 of these items in memory (the sample clocks in about 64 kilobytes, so less than a megabyte in total for 10,000 items), what is the best collection to use on android to store these objects in memory, and what is the fastest way to populate that object with data, and then find matching elements?