I basically need a data structure that works just like a Set
, but that not only maintains insert order as let's me get them later by a get(index)
method.
What is the data structure best suited to achieve this? I wouldn't have a problem in having to implement one, if needed. In the worse case I could just use both an ArrayList and a HashSet, but I'm wondering whether there is a specialized data structure up to the task.
Performance is paramount (otherwise I could just do a O(n)
search over a regular list!) and I'm not that worried about spatial complexity.