I have a list of items(i.e Strings) which I need to sort/filter.
The end result should not contain any duplicate (easy), I’ll put them all in the Set. So I have a Set of strings now.
more explanation..
I also have a method x that calculates the amount of difference between two Strings (using levenstein distance).
Question:
Before inserting new String string into my Set set I want to check for levenstein distance using method x between string and any other String in the set and if x returns >=3 than I should not add it.
What is my best shot of doing this? Except iterate trough set for each string to be inserted?
Iterating through the
Setis going to be your best bet, since there isn’t any built-inSetimplementation that would help you narrow the possibilities.