Right now I'm making a class called Stopwatch
for a Windows phone app. I need a dynamic data to add laps like a stopwatch does. That is, if a user presses the lap button while the stopwatch is running, it adds a data structure
struct lap
{
unsigned double start;
unsigned double stop;
}
(defined as a private variable in my Stopwatch
class) to the end of some sort of dynamic data structure that is saving all the laps.
Now, Bjarne Stroustrup himself says that we should always use std::vector
over linked lists: https://www.youtube.com/watch?v=YQs6IC-vgmo. So the Lord of C++ tells me that I should have
std::vector<Stopwatch::lap> Laps;
as a private variable in my class. However, at the same time, I don't need anywhere near all the functionalities of an std::vector
, since the only things I'll be using it for is iterating through the elements and using push_back()
. Should I create another generic linked list class that is limited to the functionalities I need?