0
Vector vs List
Hi I have millions of data to be stored within application. I am not having any need to access it in between. In other words, I will store data in data structure at end as and when data is available. Once this stage is over, i just need to iterate over all the data As i dont need random access , i am planning to store in list rather than vector. I cant uae vector as it needs contigous space and that much is not available. So I am planing to opt for list. Is this choice ok ? Apart from this, is it like list will be slower compared to vector due to cache locality ? Will this give huge performance degradation due to opt in of list instead of vector.
4 ответов
+ 1
Id imagine you would take a performance hit if and when freeing up the list
+ 1
Thanks Raul Ramirez for your response
To confirm my understanding, do you mean clearing data from vector is faster operation than clearing data from list? (Clearing data here means all data available is large in count and clearing all of them)
+ 1
Yes since vectors allocates in a contigous space, its easy to clear that space ( constant time )
With a list youd have to go to each location to clear it ( linear time )
0
Thanks Raul Ramirez