During my daily work, I am always advised by senior member of the team that list is not cache friendly so I should vector
. I understand that list
is not continuous so that the memory allocation is scattered around the whole memory.
However, very often I do need the functionality of a list
(or a map
). So I am wondering if I can write my own allocator, which is a vector
underneath. Every time when I push_back
, my own allocator will allocate a new item from a per-allocated vector
.
When I travel the list
/map
, the cache locality is preserved.
Does this make sense to any of you?