Code:
#include iostream
#include map
#include vector
#include ctime
struct value {
std::string code;
std::string date;
std::string name;
};
void Print_Range(std::vector
{
std::map
for(auto Date_Object : Array_Of_Dates)
{
time_t Object_Time = GetDateFromObject(Date_Object);
Associated_Data.insert(std::make_pair(Object_Time, & Date_Object);
}
//as the std::map is sorted by-default,
//we can know locate the iterator for any two time codes
time_t Search_From = GetDateFromObject(Date_Start);
time_t Search_To = GetDateFromObject(Date_End);
auto Start_IT = Associated_Data.find(Search_From);
auto End_IT = Associated_Data.find(Search_To);
std::cout << "Printing all dates in range \n";
for(auto IT=Start_IT; IT != End_IT; IT++)
{
std::cout << IT->Second->date << '\n';
}
}
Output:
Execute and get the output.
More C++ Programs: