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.

19th Dec 2022, 12:14 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
4 ответов
+ 1
Id imagine you would take a performance hit if and when freeing up the list
26th Dec 2022, 7:49 AM
Raul Ramirez
Raul Ramirez - avatar
+ 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)
26th Dec 2022, 8:20 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 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 )
27th Dec 2022, 6:28 AM
Raul Ramirez
Raul Ramirez - avatar
0
27th Dec 2022, 6:45 AM
Ketan Lalcheta
Ketan Lalcheta - avatar