c++ - Is there ever a reason to use std::list? -


this question has answer here:

after having read this question , looking @ results here, seems 1 should altogether avoid lists in c++. expected linked lists containers of choice cases need iterate on contents because insertion matter of pointer manipulation , there never need reallocate.

apparently, because of "cache locality," lists iterated on slowly, benefit having use less reserve memory or faster addition (which not faster, seems, second link) doesn't seem worth it.

having said that, when should i, performance standpoint, use std::list on std::deque or, if possible, std::vector?

on side note, std::forward_list have lots of cache misses?

when should i, performance standpoint, use std::list

from performance standpoint, rarely. situation comes mind if have many lists need split , join form other lists; linked list can without allocating memory or moving objects.

the real benefit of list stability: elements don't need movable, , iterators , references never invalidated unless refer element that's been erased.

on side note, std::forward_list have lots of cache misses?

yes; it's still linked list.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -