+ 2
Array, Set, Dictionary. Which one is quickest? And next one? Then why?
Array, Set, Dictionary. Which one is quickest? And next one? Then why?
1 Antwort
+ 2
I think plain array is the quickest, because against dictionary and Set, it keeps all the data in a contiguous chunk of memory. Dictionary and Set have a flexible lenght so they are more complex.
Set is designed for quick performance and has many types depends on the data you want to store and the way you want to get it back.
Dictionary can be considered as an advanced Set with more possibilities.
I would say first comes Array, then Set and finally the more complex Dictionary.
This was the theoretical part. In the practise, the "quickness" depends on the data type you store and the way you need to retrieve/save data with the collection.
Considering average amount of data, usually there is not any visible performance difference.