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
);
18 Snapshot
*SnapshotList::get_snapshot_for(const Timestamp
×tamp
) 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 . . . */
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());
29 s
->set_head_node(internal_list
[i
]->get_head_node());