Hi all:
I am having trouble creating an stl::set. The set needs to contain a list of times, like 0, 1, 2, 3,....
I can create a vector of what I need (below), but I'm having no success in translating it to a set or indexing the set (can't use mySet like with vectors). If anyone could help, I would be very grateful!
I guess I don't really understand the concept of sets. Any tips on their advantages over vectors would be very welcome if you have time!
// Vector of output times
std::vector<long> myOutputTimesContainer; // This would be std::set<long> myOutputTimesContainer
long numberOfTimesNeeded = (max_time / timeIncrement); // This would stay the same
myOutputTimesContainer.resize( ( numberOfTimesNeeded + 2 ), 0 ); // Would this become: myOutputTimesContainer.insert( numberOfTimesNeeded + 2 )?
myOutputTimesContainer[0] = 0;
myOutputTimesContainer[ myOutputTimesContainer.size()-1] = max_time; // Ensure that final time is always max time.
for( int i = 1; i < ( numberOfTimesNeeded + 1); i++ )
{
myOutputTimesContainer = timeIncrement + myOutputTimesContainer[i-1];
}
I am having trouble creating an stl::set. The set needs to contain a list of times, like 0, 1, 2, 3,....
I can create a vector of what I need (below), but I'm having no success in translating it to a set or indexing the set (can't use mySet like with vectors). If anyone could help, I would be very grateful!
I guess I don't really understand the concept of sets. Any tips on their advantages over vectors would be very welcome if you have time!
// Vector of output times
std::vector<long> myOutputTimesContainer; // This would be std::set<long> myOutputTimesContainer
long numberOfTimesNeeded = (max_time / timeIncrement); // This would stay the same
myOutputTimesContainer.resize( ( numberOfTimesNeeded + 2 ), 0 ); // Would this become: myOutputTimesContainer.insert( numberOfTimesNeeded + 2 )?
myOutputTimesContainer[0] = 0;
myOutputTimesContainer[ myOutputTimesContainer.size()-1] = max_time; // Ensure that final time is always max time.
for( int i = 1; i < ( numberOfTimesNeeded + 1); i++ )
{
myOutputTimesContainer = timeIncrement + myOutputTimesContainer[i-1];
}