This content has been marked as final. Show 2 replies
You can maintain two collections. One Map from Key to entry, not the index and another a List.
However, as your collections are likely to be small (ie << 1 million entries) a brute force search will be so fast it won't make a difference on a GUI.
Searching through 10K Strings takes about 25 us, 100K String takes about 900 us, 1 million Strings takes about 7000 us or 7ms which a refresh rate for a fast gaming console (but no human can see).
It's for the sake of readibility, a simple
is much more readable than the cycle-based equivalent.
I find that this situation is frequent enough to embed the possible search code in the 'general' collection class and not in the businness logic.