
Barend Gehrels wrote:
You are just storing the number of people living on any particular date. Try changing your code to record all of the names, e.g. something like: Yes, I did this in my review. The first version of my program listed like this: typedef boost::itl::set<std::string> itl_set_string; typedef boost::itl::interval_map<int, itl_set_string> itl_map; (...) itl_set_string person; person.insert(p.indi.name);
int death_date = p.indi.death.date.hasdate ? p.indi.death.date.year : 9999; livetimes.add(std::make_pair( boost::itl::interval<int>::rightopen(p.indi.birth.date.year, death_date), person)); (...) itl_set_string const& who = it->second; stream << when.first() << " - " << when.upper() << " : " << who.size() << std::endl;
Also this first test did have no noticeable delay. It is subsecond, and I did also write the names of all these persons in this test which should not be timed, so it is not problematic.
Because you're using only the years of birth and death, this is limited to O(N_YEARS * N_PEOPLE). With N_YEARS ~ hundreds and N_PEOPLE ~ thousands, I can believe this would run in a short time (modern computers are fast). If you have time, I would be interested to know how the performance changes if you use a higher-resolution date type, e.g. integer number of days. Regards, Phil.