Reputation: 1765
I need to create a keyed array that I can push data to.
I need to store id and time, and on an event push a new id and time to the array.
After a look around, many people have suggested vectors.
I'm not sure how I would implement it though, having two keys, and how to push to them?
If anyone could help?
Upvotes: 0
Views: 89
Reputation: 500367
Use a std::vector
of std::pair<T,U>
, where T
and U
are suitable data types for the id and the time.
For example:
std::vector<std::pair<int, long> > v;
v.push_back(std::make_pair(1, 2L));
v.push_back(std::make_pair(1, 2L));
v.push_back(std::make_pair(2, 2L));
Upvotes: 1