I was going through a tutorial on Containers from the C++ standard library and was taken aback when the instructor told that the size of the std::list
isn't stored as part of the list, instead it is found by traversing through the list end to end and returning the count unlike with std::vector
.
Is this true?! If yes, why don't they just store the size as part of the class and update the size every time a node is added or removed from the list? What am I missing here?