H
Henrik Goldman
I have a std::map which consist of time_t as first and an associated class
as second:
map<time_t, myclass>
I would like to do calculations (min and max values) for a set of 'second'
for a specific time range.
Given the fact that 'first' can hold any time I would like to do the
calculation based on values which falls within a range of e.g. yesterday
(all 24 hours). So I'd like to efficiently find the first value of time_t
which meets this requirement.
Until now I've scanned forward by an iterator but if you have alot of values
this linear search becomes quite slow. This has become a problem to me. The
problem boils down to that I don't know the exact 'first' value that I'm
looking for but know within what timerange it should fall.
Are there any stl algorithms which can let me define my own compare
algorithm so I can do this time range checking in order to find the first
valid element? Naturally since time_t is just an integer the algorithm
should be faster then linear search.
Thanks in advance.
-- Henrik
as second:
map<time_t, myclass>
I would like to do calculations (min and max values) for a set of 'second'
for a specific time range.
Given the fact that 'first' can hold any time I would like to do the
calculation based on values which falls within a range of e.g. yesterday
(all 24 hours). So I'd like to efficiently find the first value of time_t
which meets this requirement.
Until now I've scanned forward by an iterator but if you have alot of values
this linear search becomes quite slow. This has become a problem to me. The
problem boils down to that I don't know the exact 'first' value that I'm
looking for but know within what timerange it should fall.
Are there any stl algorithms which can let me define my own compare
algorithm so I can do this time range checking in order to find the first
valid element? Naturally since time_t is just an integer the algorithm
should be faster then linear search.
Thanks in advance.
-- Henrik