I have a huge array list which contains 1000 entries out of which one of the entry is “world”. And, I have a word “big world”. I want to get the word “big world” matched with “world” in the arraylist.
What is the most cost effective way of doing it? I cannot use .contains method of array list, and If I traverse all the 1000 entries and match them by pattern its going to be very costly in terms of performance. I am using Java for this.
Could you please let me know what is the best way for this?
Cheers,
J
You can split up every single element of the
ArrayListinto words and stop as soon as you find one of them.I suppose by your profile you develop in Java, with Lucene you would easily do something like that
Note: this is Groovy code that I copied from a personal project so you will have to translate things like
Data.stopWords.collect{ it.text } as String[]to use with plain Java