When is it preferable to use std::list over std::vector while working with fairly small objects (no more than 32 bits)?
Explanation
The correct answer is: when inserting to the beginning. The vector performs other operations faster due to the fact that std::list more often allocates memory; iterating through std::list takes much longer than the vector.
Read more: C++ benchmark – std::vector VS std::list VS std::deque

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты