I am tasked with creating a data structure that contains a logical value for every minute of the last 24 hours. (Did event X happen?) I need to keep the last 24 hours all the time. (That is, data will be constantly added, old data will be deleted.) Data must be stored on a flash drive. We are on the embedded platform, but the memory is not limited (I have 128 MB), however fragmentation can be a problem. This is a real-time system, but since recording per minute, there are slight run-time limitations.
The interface might look something like this:
class x_record {
public:
void record_entry(bool x_occured);
unsigned int x_occurance_minutes() const;
private:
};
What would be a good data structure for storing actual data? My favorites are an std::deque<bool>array of 24 long long, with 60 of their 64 bits each being used for 60 minutes per hour. The latter is a favorite for perseverance.
I think I have a pretty good idea of the pros and cons of both ideas, but I hope that some of you can provide additional insights and possibly even more ideas.
PS: This is strictly C ++ 03 + TR1 + Boost 1.52, not C ++ 11/14 available.
source
share