Hi,
Assume you need to store/retrieve items in a Collection
, don't care about ordering, and duplicates are allowed, what type of Collection
do you use?
By default, I've always used ArrayList
, but I remember reading/hearing somewhere that a Queue
implementation may be a better choice. A List
allows items to be added/retrieved/removed at arbitrary positions, which incurs a performance penalty. As a Queue
does not provide this facility it should in theory be faster when this facility is not required.
I realise that all discussions about performance are somewhat meaningless, the only thing that really matters is measurement. Nevertheless, I'm interested to know what others use for a Collection
, when they don't care about ordering, and duplicates are allowed, and why?
Thanks, Don