From: Joel Holdsworth Date: Sat, 8 Feb 2014 09:48:48 +0000 (+0000) Subject: RowData: Removed _ann_start_index and _ann_end_index X-Git-Tag: pulseview-0.2.0~86 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=21ea5e700fdde6a6eb2c0969649fcb1d8ea6d283;p=pulseview.git RowData: Removed _ann_start_index and _ann_end_index This fixes #308 --- diff --git a/pv/data/decode/rowdata.cpp b/pv/data/decode/rowdata.cpp index a06af616..b1c256ac 100644 --- a/pv/data/decode/rowdata.cpp +++ b/pv/data/decode/rowdata.cpp @@ -18,10 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - -#include - #include "rowdata.h" using std::vector; @@ -42,75 +38,19 @@ uint64_t RowData::get_max_sample() const } void RowData::get_annotation_subset( - std::vector &dest, + vector &dest, uint64_t start_sample, uint64_t end_sample) const { - const vector::const_iterator start_iter = - lower_bound(_ann_end_index.begin(), - _ann_end_index.end(), start_sample, - bind(&RowData::index_entry_end_sample_lt, - this, _1, _2)); - - const vector::const_iterator end_iter = - upper_bound(_ann_start_index.begin(), - _ann_start_index.end(), end_sample, - bind(&RowData::index_entry_start_sample_gt, - this, _1, _2)); - - for (vector::const_iterator i = start_iter; - i != _ann_end_index.end() && *i != *end_iter; i++) - dest.push_back(_annotations[*i]); + for (vector::const_iterator i = _annotations.begin(); + i != _annotations.end(); i++) + if ((*i).end_sample() > start_sample && + (*i).start_sample() < end_sample) + dest.push_back(*i); } void RowData::push_annotation(const Annotation &a) { - const size_t offset = _annotations.size(); _annotations.push_back(a); - - // Insert the annotation into the start index - vector::iterator i = _ann_start_index.end(); - if (!_ann_start_index.empty() && - _annotations[_ann_start_index.back()].start_sample() > - a.start_sample()) - i = upper_bound(_ann_start_index.begin(), - _ann_start_index.end(), a.start_sample(), - bind(&RowData::index_entry_start_sample_gt, - this, _1, _2)); - - _ann_start_index.insert(i, offset); - - // Insert the annotation into the end index - vector::iterator j = _ann_end_index.end(); - if (!_ann_end_index.empty() && - _annotations[_ann_end_index.back()].end_sample() < - a.end_sample()) - j = upper_bound(_ann_end_index.begin(), - _ann_end_index.end(), a.end_sample(), - bind(&RowData::index_entry_end_sample_gt, - this, _1, _2)); - - _ann_end_index.insert(j, offset); -} - -bool RowData::index_entry_start_sample_gt( - const uint64_t sample, const size_t index) const -{ - assert(index < _annotations.size()); - return _annotations[index].start_sample() > sample; -} - -bool RowData::index_entry_end_sample_lt( - const size_t index, const uint64_t sample) const -{ - assert(index < _annotations.size()); - return _annotations[index].end_sample() < sample; -} - -bool RowData::index_entry_end_sample_gt( - const uint64_t sample, const size_t index) const -{ - assert(index < _annotations.size()); - return _annotations[index].end_sample() > sample; } } // decode diff --git a/pv/data/decode/rowdata.h b/pv/data/decode/rowdata.h index 3cd454e3..01c65b6e 100644 --- a/pv/data/decode/rowdata.h +++ b/pv/data/decode/rowdata.h @@ -44,25 +44,10 @@ public: std::vector &dest, uint64_t start_sample, uint64_t end_sample) const; - void push_annotation(const Annotation& a); - -private: - bool index_entry_start_sample_gt( - const uint64_t sample, const size_t index) const; - bool index_entry_end_sample_lt( - const size_t index, const uint64_t sample) const; - bool index_entry_end_sample_gt( - const uint64_t sample, const size_t index) const; + void push_annotation(const Annotation &a); private: std::vector _annotations; - - /** - * _ann_start_index and _ann_end_index contain lists of annotions - * (represented by offsets in the _annotations vector), sorted in - * ascending ordered by the start_sample and end_sample respectively. - */ - std::vector _ann_start_index, _ann_end_index; }; }