Well, that would be why the ActiveBlocks data isn't correct . . .
[aesalon.git] / gui / src / storage / SnapshotList.cpp
blob1bcd150baa09570589fae7daca7ec854f8ca7d81
1 #include "SnapshotList.h"
3 SnapshotList::SnapshotList() : last_id(0) {
7 SnapshotList::~SnapshotList() {
11 Snapshot *SnapshotList::append_snapshot() {
12 Snapshot *s = new Snapshot(++last_id);
13 if(internal_list.size()) s->set_head_node(internal_list.back()->get_head_node());
14 internal_list.append(s);
15 return s;
18 Snapshot *SnapshotList::get_snapshot_for(const Timestamp &timestamp) const {
19 Snapshot *s = new Snapshot(-1);
20 /* NOTE: speed this up via a binary-style search through the list: try size/2, size/2+size/4 or size/2-size/4 . . . */
21 int i;
22 for(i = 0; i < internal_list.size(); i ++) {
23 if(internal_list[i]->get_timestamp() >= timestamp) break;
25 if(i == internal_list.size()) {
26 qDebug("Couldn't find snapshot for requested time: %s", timestamp.to_string().toStdString().c_str());
27 return NULL;
29 s->set_head_node(internal_list[i]->get_head_node());
30 return s;