Prompt the best collection in terms of performance in a situation where you need to create and replenish it very often. In this case, the order of adding elements should be preserved, and the elements in the collection are few, maximum 30 pieces.
4 answers
Only Vector and Stack are no longer used, instead of them (to replace a collection with synchronization) - CopyOnWriteArrayList .
PS Looks like you need LinkedList .
- visually. Interestingly, is there a similar under C #? - AK ♦
- one@AK is only a site with something similar, maybe someone will do a picchu. docs.microsoft.com/ru-ru/dotnet/standard/collections/… - Anton Sorokin
You need a list. At 30 elements take ArrayList. Even when you insert a shift into the beginning, 29 elements are quite comparable in speed (although, maybe slower, did not check) with memory allocation and permutation of 6 links, besides, you will receive data in the processor cache, which will ensure quick access to them later.
- Plus The maximum use of cache is so apparently driving. - Alexander Petrov
- I previously found a recommendation to use ArrayDeque, and what do you think about this? - ProstoCoder
If the main operation is an addition, then use the list because insertion of the item in O (1) occurs.
- 2Which list exactly? After all, they are different in speed, in order to preserve the order of addition, etc., they have many differences. - Anton Sorokin
ArrayList if inserting elements in the beginning, LinkedList if in the middle. Although, for 30 elements, as stated above, you can use any of these options
- With a fright Linked to this question? - Qwertiy ♦
- Already fixed, on the contrary :) - Nikita
- Yes, the opposite is better :) - Qwertiy ♦

ConcurrentHashMapwill do. - And