I must work with a Collection
, and I am not sure about using a List
or a Set
. This collection must be sorted, but not by the order of insertion but for another one, so each time a new item is added, a Comparator
should be executed in order to reorder the Collection
. So, for this reason, an ArrayList
could be the best option.
Removing objects from that Collection
must be possible too, furthermore, I would really appreciate using removeIf
method, so a Set
would be the best option here.
Getting and iterating over the Collection
will be the most repeated scenario, so it must have a good performance in this scenario.
Seeing that, I think that a Set
would be a good decision, however, I was thinking about converting the Set
into a List
when adding items, then, once the list has been resorted, converting it back to a Set
. Is it bad performing? What do you think?
Thanks in advance