mirror of
https://github.com/tstack/lnav.git
synced 2024-08-17 00:40:30 +03:00
[mark-expr] expression marks should count when showing elapsed time
This commit is contained in:
parent
bd1b90a101
commit
d5b06fca5f
@ -121,7 +121,7 @@ public:
|
|||||||
* the next bookmark is returned. If the 'start' value is not a
|
* the next bookmark is returned. If the 'start' value is not a
|
||||||
* bookmark, the next highest value in the vector is returned.
|
* bookmark, the next highest value in the vector is returned.
|
||||||
*/
|
*/
|
||||||
LineType next(LineType start) const;
|
nonstd::optional<LineType> next(LineType start) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start The value to start the search for the previous
|
* @param start The value to start the search for the previous
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
* are no more prior bookmarks.
|
* are no more prior bookmarks.
|
||||||
* @see next
|
* @see next
|
||||||
*/
|
*/
|
||||||
LineType prev(LineType start) const;
|
nonstd::optional<LineType> prev(LineType start) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,10 +162,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename LineType>
|
template<typename LineType>
|
||||||
LineType
|
nonstd::optional<LineType>
|
||||||
bookmark_vector<LineType>::next(LineType start) const
|
bookmark_vector<LineType>::next(LineType start) const
|
||||||
{
|
{
|
||||||
LineType retval(-1);
|
nonstd::optional<LineType> retval;
|
||||||
|
|
||||||
require(start >= -1);
|
require(start >= -1);
|
||||||
|
|
||||||
@ -174,16 +174,16 @@ bookmark_vector<LineType>::next(LineType start) const
|
|||||||
retval = *ub;
|
retval = *ub;
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure(retval == -1 || start < retval);
|
ensure(!retval || start < retval.value());
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename LineType>
|
template<typename LineType>
|
||||||
LineType
|
nonstd::optional<LineType>
|
||||||
bookmark_vector<LineType>::prev(LineType start) const
|
bookmark_vector<LineType>::prev(LineType start) const
|
||||||
{
|
{
|
||||||
LineType retval(-1);
|
nonstd::optional<LineType> retval;
|
||||||
|
|
||||||
require(start >= 0);
|
require(start >= 0);
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ bookmark_vector<LineType>::prev(LineType start) const
|
|||||||
retval = *lb;
|
retval = *lb;
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure(retval < start);
|
ensure(!retval || retval.value() < start);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -313,8 +313,8 @@ handle_paging_key(int ch)
|
|||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if (tc == &lnav_data.ld_views[LNV_LOG]) {
|
if (tc == &lnav_data.ld_views[LNV_LOG]) {
|
||||||
tc->set_top(
|
bm[&logfile_sub_source::BM_FILES].next(tc->get_top()) |
|
||||||
bm[&logfile_sub_source::BM_FILES].next(tc->get_top()));
|
[&tc](auto vl) { tc->set_top(vl); };
|
||||||
} else if (tc == &lnav_data.ld_views[LNV_TEXT]) {
|
} else if (tc == &lnav_data.ld_views[LNV_TEXT]) {
|
||||||
textfile_sub_source& tss = lnav_data.ld_text_source;
|
textfile_sub_source& tss = lnav_data.ld_text_source;
|
||||||
|
|
||||||
@ -327,8 +327,8 @@ handle_paging_key(int ch)
|
|||||||
|
|
||||||
case 'F':
|
case 'F':
|
||||||
if (tc == &lnav_data.ld_views[LNV_LOG]) {
|
if (tc == &lnav_data.ld_views[LNV_LOG]) {
|
||||||
tc->set_top(
|
bm[&logfile_sub_source::BM_FILES].prev(tc->get_top()) |
|
||||||
bm[&logfile_sub_source::BM_FILES].prev(tc->get_top()));
|
[&tc](auto vl) { tc->set_top(vl); };
|
||||||
} else if (tc == &lnav_data.ld_views[LNV_TEXT]) {
|
} else if (tc == &lnav_data.ld_views[LNV_TEXT]) {
|
||||||
textfile_sub_source& tss = lnav_data.ld_text_source;
|
textfile_sub_source& tss = lnav_data.ld_text_source;
|
||||||
|
|
||||||
|
@ -3211,22 +3211,25 @@ com_clear_partition(exec_context& ec,
|
|||||||
= tc.get_bookmarks()[&textview_curses::BM_META];
|
= tc.get_bookmarks()[&textview_curses::BM_META];
|
||||||
std::map<content_line_t, bookmark_metadata>& bm
|
std::map<content_line_t, bookmark_metadata>& bm
|
||||||
= lss.get_user_bookmark_metadata();
|
= lss.get_user_bookmark_metadata();
|
||||||
vis_line_t part_start;
|
nonstd::optional<vis_line_t> part_start;
|
||||||
|
|
||||||
if (binary_search(bv.begin(), bv.end(), tc.get_top())) {
|
if (binary_search(bv.begin(), bv.end(), tc.get_top())) {
|
||||||
part_start = tc.get_top();
|
part_start = tc.get_top();
|
||||||
} else {
|
} else {
|
||||||
part_start = bv.prev(tc.get_top());
|
part_start = bv.prev(tc.get_top());
|
||||||
}
|
}
|
||||||
if (part_start == -1) {
|
if (!part_start) {
|
||||||
return ec.make_error("top line is not in a partition");
|
return ec.make_error("top line is not in a partition");
|
||||||
} else if (!ec.ec_dry_run) {
|
}
|
||||||
content_line_t cl = lss.at(part_start);
|
|
||||||
|
if (!ec.ec_dry_run) {
|
||||||
|
content_line_t cl = lss.at(part_start.value());
|
||||||
bookmark_metadata& line_meta = bm[cl];
|
bookmark_metadata& line_meta = bm[cl];
|
||||||
|
|
||||||
line_meta.bm_name.clear();
|
line_meta.bm_name.clear();
|
||||||
if (line_meta.empty()) {
|
if (line_meta.empty()) {
|
||||||
tc.set_user_mark(&textview_curses::BM_META, part_start, false);
|
tc.set_user_mark(
|
||||||
|
&textview_curses::BM_META, part_start.value(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = "info: cleared partition name";
|
retval = "info: cleared partition name";
|
||||||
|
@ -44,30 +44,29 @@ public:
|
|||||||
{
|
{
|
||||||
textview_curses* tc = (textview_curses*) &lv;
|
textview_curses* tc = (textview_curses*) &lv;
|
||||||
vis_bookmarks& bm = tc->get_bookmarks();
|
vis_bookmarks& bm = tc->get_bookmarks();
|
||||||
vis_line_t next;
|
|
||||||
bool search_hit = false;
|
bool search_hit = false;
|
||||||
|
|
||||||
start -= 1;
|
start -= 1;
|
||||||
|
|
||||||
next = bm[&textview_curses::BM_SEARCH].next(vis_line_t(start));
|
auto next = bm[&textview_curses::BM_SEARCH].next(vis_line_t(start));
|
||||||
search_hit = (next != -1 && next <= end);
|
search_hit = (next && next.value() <= end);
|
||||||
|
|
||||||
next = bm[&textview_curses::BM_USER].next(vis_line_t(start));
|
next = bm[&textview_curses::BM_USER].next(vis_line_t(start));
|
||||||
if (next == -1) {
|
if (!next) {
|
||||||
next = bm[&textview_curses::BM_META].next(vis_line_t(start));
|
next = bm[&textview_curses::BM_META].next(vis_line_t(start));
|
||||||
}
|
}
|
||||||
if (next != -1 && next <= end) {
|
if (next && next.value() <= end) {
|
||||||
ch = search_hit ? ACS_PLUS : ACS_LTEE;
|
ch = search_hit ? ACS_PLUS : ACS_LTEE;
|
||||||
} else {
|
} else {
|
||||||
ch = search_hit ? ACS_RTEE : ACS_VLINE;
|
ch = search_hit ? ACS_RTEE : ACS_VLINE;
|
||||||
}
|
}
|
||||||
next = bm[&logfile_sub_source::BM_ERRORS].next(vis_line_t(start));
|
next = bm[&logfile_sub_source::BM_ERRORS].next(vis_line_t(start));
|
||||||
if (next != -1 && next <= end) {
|
if (next && next.value() <= end) {
|
||||||
role_out = role_t::VCR_ERROR;
|
role_out = role_t::VCR_ERROR;
|
||||||
bar_role_out = role_t::VCR_SCROLLBAR_ERROR;
|
bar_role_out = role_t::VCR_SCROLLBAR_ERROR;
|
||||||
} else {
|
} else {
|
||||||
next = bm[&logfile_sub_source::BM_WARNINGS].next(vis_line_t(start));
|
next = bm[&logfile_sub_source::BM_WARNINGS].next(vis_line_t(start));
|
||||||
if (next != -1 && next <= end) {
|
if (next && next.value() <= end) {
|
||||||
role_out = role_t::VCR_WARNING;
|
role_out = role_t::VCR_WARNING;
|
||||||
bar_role_out = role_t::VCR_SCROLLBAR_WARNING;
|
bar_role_out = role_t::VCR_SCROLLBAR_WARNING;
|
||||||
}
|
}
|
||||||
|
@ -315,23 +315,25 @@ logfile_sub_source::text_value_for_line(textview_curses& tc,
|
|||||||
if (this->lss_flags & F_TIME_OFFSET) {
|
if (this->lss_flags & F_TIME_OFFSET) {
|
||||||
auto curr_tv = this->lss_token_line->get_timeval();
|
auto curr_tv = this->lss_token_line->get_timeval();
|
||||||
struct timeval diff_tv;
|
struct timeval diff_tv;
|
||||||
|
auto row_vl = vis_line_t(row);
|
||||||
|
|
||||||
vis_line_t prev_mark
|
auto prev_umark
|
||||||
= tc.get_bookmarks()[&textview_curses::BM_USER].prev(
|
= tc.get_bookmarks()[&textview_curses::BM_USER].prev(row_vl);
|
||||||
vis_line_t(row));
|
auto next_umark
|
||||||
vis_line_t next_mark
|
= tc.get_bookmarks()[&textview_curses::BM_USER].next(row_vl);
|
||||||
= tc.get_bookmarks()[&textview_curses::BM_USER].next(
|
auto prev_emark
|
||||||
vis_line_t(row));
|
= tc.get_bookmarks()[&textview_curses::BM_USER_EXPR].prev(row_vl);
|
||||||
if (prev_mark == -1 && next_mark != -1) {
|
auto next_emark
|
||||||
auto next_line = this->find_line(this->at(next_mark));
|
= tc.get_bookmarks()[&textview_curses::BM_USER_EXPR].next(row_vl);
|
||||||
|
if (!prev_umark && !prev_emark && (next_umark || next_emark)) {
|
||||||
|
auto next_line = this->find_line(this->at(
|
||||||
|
std::max(next_umark.value_or(0), next_emark.value_or(0))));
|
||||||
|
|
||||||
diff_tv = curr_tv - next_line->get_timeval();
|
diff_tv = curr_tv - next_line->get_timeval();
|
||||||
} else {
|
} else {
|
||||||
if (prev_mark == -1_vl) {
|
auto prev_row
|
||||||
prev_mark = 0_vl;
|
= std::max(prev_umark.value_or(0), prev_emark.value_or(0));
|
||||||
}
|
auto first_line = this->find_line(this->at(prev_row));
|
||||||
|
|
||||||
auto first_line = this->find_line(this->at(prev_mark));
|
|
||||||
auto start_tv = first_line->get_timeval();
|
auto start_tv = first_line->get_timeval();
|
||||||
diff_tv = curr_tv - start_tv;
|
diff_tv = curr_tv - start_tv;
|
||||||
}
|
}
|
||||||
@ -1918,10 +1920,11 @@ logfile_sub_source::meta_grepper::grep_next_line(vis_line_t& line)
|
|||||||
vis_bookmarks& bm = this->lmg_source.tss_view->get_bookmarks();
|
vis_bookmarks& bm = this->lmg_source.tss_view->get_bookmarks();
|
||||||
bookmark_vector<vis_line_t>& bv = bm[&textview_curses::BM_META];
|
bookmark_vector<vis_line_t>& bv = bm[&textview_curses::BM_META];
|
||||||
|
|
||||||
line = bv.next(vis_line_t(line));
|
auto line_opt = bv.next(vis_line_t(line));
|
||||||
if (line == -1) {
|
if (!line_opt) {
|
||||||
this->lmg_done = true;
|
this->lmg_done = true;
|
||||||
}
|
}
|
||||||
|
line = line_opt.value_or(-1_vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -622,16 +622,16 @@ rl_callback_int(readline_curses* rc, bool is_alt)
|
|||||||
auto_mem<FILE> pfile(pclose);
|
auto_mem<FILE> pfile(pclose);
|
||||||
vis_bookmarks& bm = tc->get_bookmarks();
|
vis_bookmarks& bm = tc->get_bookmarks();
|
||||||
const auto& bv = bm[&textview_curses::BM_SEARCH];
|
const auto& bv = bm[&textview_curses::BM_SEARCH];
|
||||||
vis_line_t vl = is_alt ? bv.prev(tc->get_top())
|
auto vl = is_alt ? bv.prev(tc->get_top())
|
||||||
: bv.next(tc->get_top());
|
: bv.next(tc->get_top());
|
||||||
|
|
||||||
pfile = sysclip::open(sysclip::type_t::FIND);
|
pfile = sysclip::open(sysclip::type_t::FIND);
|
||||||
if (pfile.in() != nullptr) {
|
if (pfile.in() != nullptr) {
|
||||||
fmt::print(
|
fmt::print(
|
||||||
pfile, FMT_STRING("{}"), rc->get_value().get_string());
|
pfile, FMT_STRING("{}"), rc->get_value().get_string());
|
||||||
}
|
}
|
||||||
if (vl != -1_vl) {
|
if (vl) {
|
||||||
tc->set_top(vl);
|
tc->set_top(vl.value());
|
||||||
} else {
|
} else {
|
||||||
tc->set_follow_search_for(2000, [tc, is_alt, &bm]() {
|
tc->set_follow_search_for(2000, [tc, is_alt, &bm]() {
|
||||||
if (bm[&textview_curses::BM_SEARCH].empty()) {
|
if (bm[&textview_curses::BM_SEARCH].empty()) {
|
||||||
@ -642,7 +642,7 @@ rl_callback_int(readline_curses* rc, bool is_alt)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vis_line_t first_hit;
|
nonstd::optional<vis_line_t> first_hit;
|
||||||
|
|
||||||
if (is_alt) {
|
if (is_alt) {
|
||||||
first_hit = bm[&textview_curses::BM_SEARCH].prev(
|
first_hit = bm[&textview_curses::BM_SEARCH].prev(
|
||||||
@ -651,11 +651,12 @@ rl_callback_int(readline_curses* rc, bool is_alt)
|
|||||||
first_hit = bm[&textview_curses::BM_SEARCH].next(
|
first_hit = bm[&textview_curses::BM_SEARCH].next(
|
||||||
vis_line_t(tc->get_top() - 1));
|
vis_line_t(tc->get_top() - 1));
|
||||||
}
|
}
|
||||||
if (first_hit != -1) {
|
if (first_hit) {
|
||||||
if (first_hit > 0) {
|
auto first_hit_vl = first_hit.value();
|
||||||
--first_hit;
|
if (first_hit_vl > 0_vl) {
|
||||||
|
--first_hit_vl;
|
||||||
}
|
}
|
||||||
tc->set_top(first_hit);
|
tc->set_top(first_hit_vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -700,10 +700,10 @@ update_hits(textview_curses* tc)
|
|||||||
|
|
||||||
auto prev_vl = bv.prev(tc->get_top());
|
auto prev_vl = bv.prev(tc->get_top());
|
||||||
|
|
||||||
if (prev_vl != -1_vl) {
|
if (prev_vl) {
|
||||||
attr_line_t al;
|
attr_line_t al;
|
||||||
|
|
||||||
tc->textview_value_for_row(prev_vl, al);
|
tc->textview_value_for_row(prev_vl.value(), al);
|
||||||
if (preview_count > 0) {
|
if (preview_count > 0) {
|
||||||
all_matches.append("\n");
|
all_matches.append("\n");
|
||||||
}
|
}
|
||||||
@ -711,15 +711,16 @@ update_hits(textview_curses* tc)
|
|||||||
sizeof(linebuf),
|
sizeof(linebuf),
|
||||||
"L%*d: ",
|
"L%*d: ",
|
||||||
max_line_width,
|
max_line_width,
|
||||||
(int) prev_vl);
|
(int) prev_vl.value());
|
||||||
all_matches.append(linebuf).append(al);
|
all_matches.append(linebuf).append(al);
|
||||||
preview_count += 1;
|
preview_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((vl = bv.next(vl)) != -1_vl
|
nonstd::optional<vis_line_t> next_vl;
|
||||||
&& preview_count < MAX_MATCH_COUNT) {
|
while ((next_vl = bv.next(vl)) && preview_count < MAX_MATCH_COUNT) {
|
||||||
attr_line_t al;
|
attr_line_t al;
|
||||||
|
|
||||||
|
vl = next_vl.value();
|
||||||
tc->textview_value_for_row(vl, al);
|
tc->textview_value_for_row(vl, al);
|
||||||
if (preview_count > 0) {
|
if (preview_count > 0) {
|
||||||
all_matches.append("\n");
|
all_matches.append("\n");
|
||||||
@ -887,7 +888,8 @@ ensure_view(lnav_view_t expected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nonstd::optional<vis_line_t>
|
nonstd::optional<vis_line_t>
|
||||||
next_cluster(vis_line_t (bookmark_vector<vis_line_t>::*f)(vis_line_t) const,
|
next_cluster(nonstd::optional<vis_line_t> (bookmark_vector<vis_line_t>::*f)(
|
||||||
|
vis_line_t) const,
|
||||||
const bookmark_type_t* bt,
|
const bookmark_type_t* bt,
|
||||||
const vis_line_t top)
|
const vis_line_t top)
|
||||||
{
|
{
|
||||||
@ -895,36 +897,37 @@ next_cluster(vis_line_t (bookmark_vector<vis_line_t>::*f)(vis_line_t) const,
|
|||||||
vis_bookmarks& bm = tc->get_bookmarks();
|
vis_bookmarks& bm = tc->get_bookmarks();
|
||||||
bookmark_vector<vis_line_t>& bv = bm[bt];
|
bookmark_vector<vis_line_t>& bv = bm[bt];
|
||||||
bool top_is_marked = binary_search(bv.begin(), bv.end(), top);
|
bool top_is_marked = binary_search(bv.begin(), bv.end(), top);
|
||||||
vis_line_t last_top(top), new_top(top), tc_height;
|
vis_line_t last_top(top), tc_height;
|
||||||
|
nonstd::optional<vis_line_t> new_top = top;
|
||||||
unsigned long tc_width;
|
unsigned long tc_width;
|
||||||
int hit_count = 0;
|
int hit_count = 0;
|
||||||
|
|
||||||
tc->get_dimensions(tc_height, tc_width);
|
tc->get_dimensions(tc_height, tc_width);
|
||||||
|
|
||||||
while ((new_top = (bv.*f)(new_top)) != -1) {
|
while ((new_top = (bv.*f)(new_top.value()))) {
|
||||||
int diff = new_top - last_top;
|
int diff = new_top.value() - last_top;
|
||||||
|
|
||||||
hit_count += 1;
|
hit_count += 1;
|
||||||
if (!top_is_marked || diff > 1) {
|
if (!top_is_marked || diff > 1) {
|
||||||
return new_top;
|
return new_top;
|
||||||
}
|
}
|
||||||
if (hit_count > 1 && std::abs(new_top - top) >= tc_height) {
|
if (hit_count > 1 && std::abs(new_top.value() - top) >= tc_height) {
|
||||||
return vis_line_t(new_top - diff);
|
return vis_line_t(new_top.value() - diff);
|
||||||
}
|
}
|
||||||
if (diff < -1) {
|
if (diff < -1) {
|
||||||
last_top = new_top;
|
last_top = new_top.value();
|
||||||
while ((new_top = (bv.*f)(new_top)) != -1) {
|
while ((new_top = (bv.*f)(new_top.value()))) {
|
||||||
if ((std::abs(last_top - new_top) > 1)
|
if ((std::abs(last_top - new_top.value()) > 1)
|
||||||
|| (hit_count > 1
|
|| (hit_count > 1
|
||||||
&& (std::abs(top - new_top) >= tc_height)))
|
&& (std::abs(top - new_top.value()) >= tc_height)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
last_top = new_top;
|
last_top = new_top.value();
|
||||||
}
|
}
|
||||||
return last_top;
|
return last_top;
|
||||||
}
|
}
|
||||||
last_top = new_top;
|
last_top = new_top.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_top != top) {
|
if (last_top != top) {
|
||||||
@ -935,7 +938,8 @@ next_cluster(vis_line_t (bookmark_vector<vis_line_t>::*f)(vis_line_t) const,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
moveto_cluster(vis_line_t (bookmark_vector<vis_line_t>::*f)(vis_line_t) const,
|
moveto_cluster(nonstd::optional<vis_line_t> (bookmark_vector<vis_line_t>::*f)(
|
||||||
|
vis_line_t) const,
|
||||||
const bookmark_type_t* bt,
|
const bookmark_type_t* bt,
|
||||||
vis_line_t top)
|
vis_line_t top)
|
||||||
{
|
{
|
||||||
|
@ -83,11 +83,12 @@ void layout_views();
|
|||||||
void update_hits(textview_curses* tc);
|
void update_hits(textview_curses* tc);
|
||||||
|
|
||||||
nonstd::optional<vis_line_t> next_cluster(
|
nonstd::optional<vis_line_t> next_cluster(
|
||||||
vis_line_t (bookmark_vector<vis_line_t>::*f)(vis_line_t) const,
|
nonstd::optional<vis_line_t> (bookmark_vector<vis_line_t>::*f)(vis_line_t)
|
||||||
|
const,
|
||||||
const bookmark_type_t* bt,
|
const bookmark_type_t* bt,
|
||||||
vis_line_t top);
|
vis_line_t top);
|
||||||
bool moveto_cluster(vis_line_t (bookmark_vector<vis_line_t>::*f)(vis_line_t)
|
bool moveto_cluster(nonstd::optional<vis_line_t> (
|
||||||
const,
|
bookmark_vector<vis_line_t>::*f)(vis_line_t) const,
|
||||||
const bookmark_type_t* bt,
|
const bookmark_type_t* bt,
|
||||||
vis_line_t top);
|
vis_line_t top);
|
||||||
void previous_cluster(const bookmark_type_t* bt, textview_curses* tc);
|
void previous_cluster(const bookmark_type_t* bt, textview_curses* tc);
|
||||||
|
@ -79,31 +79,31 @@ main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
bv.clear();
|
bv.clear();
|
||||||
assert(bv.next(vis_line_t(0)) == -1);
|
assert(!bv.next(vis_line_t(0)));
|
||||||
assert(bv.prev(vis_line_t(0)) == -1);
|
assert(!bv.prev(vis_line_t(0)));
|
||||||
assert(bv.next(vis_line_t(100)) == -1);
|
assert(!bv.next(vis_line_t(100)));
|
||||||
assert(bv.prev(vis_line_t(100)) == -1);
|
assert(!bv.prev(vis_line_t(100)));
|
||||||
|
|
||||||
bv.insert_once(vis_line_t(2));
|
bv.insert_once(vis_line_t(2));
|
||||||
|
|
||||||
assert(bv.next(vis_line_t(0)) == 2);
|
assert(bv.next(vis_line_t(0)).value() == 2);
|
||||||
assert(bv.next(vis_line_t(2)) == -1);
|
assert(!bv.next(vis_line_t(2)));
|
||||||
assert(bv.next(vis_line_t(3)) == -1);
|
assert(!bv.next(vis_line_t(3)));
|
||||||
|
|
||||||
assert(bv.prev(vis_line_t(3)) == 2);
|
assert(bv.prev(vis_line_t(3)).value() == 2);
|
||||||
assert(bv.prev(vis_line_t(2)) == -1);
|
assert(!bv.prev(vis_line_t(2)));
|
||||||
|
|
||||||
bv.insert_once(vis_line_t(4));
|
bv.insert_once(vis_line_t(4));
|
||||||
|
|
||||||
assert(bv.next(vis_line_t(0)) == 2);
|
assert(bv.next(vis_line_t(0)).value() == 2);
|
||||||
assert(bv.next(vis_line_t(2)) == 4);
|
assert(bv.next(vis_line_t(2)).value() == 4);
|
||||||
assert(bv.next(vis_line_t(3)) == 4);
|
assert(bv.next(vis_line_t(3)).value() == 4);
|
||||||
assert(bv.next(vis_line_t(4)) == -1);
|
assert(!bv.next(vis_line_t(4)));
|
||||||
|
|
||||||
assert(bv.prev(vis_line_t(10)) == 4);
|
assert(bv.prev(vis_line_t(10)).value() == 4);
|
||||||
assert(bv.prev(vis_line_t(5)) == 4);
|
assert(bv.prev(vis_line_t(5)).value() == 4);
|
||||||
assert(bv.prev(vis_line_t(4)) == 2);
|
assert(bv.prev(vis_line_t(4)).value() == 2);
|
||||||
assert(bv.prev(vis_line_t(2)) == -1);
|
assert(!bv.prev(vis_line_t(2)));
|
||||||
|
|
||||||
bv.clear();
|
bv.clear();
|
||||||
|
|
||||||
@ -121,7 +121,8 @@ main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
vis_line_t last_line(-1);
|
vis_line_t last_line(-1);
|
||||||
|
|
||||||
for (lpc = 0; lpc != -1; lpc = bv.next(vis_line_t(lpc))) {
|
for (lpc = 0; lpc != -1; lpc = bv.next(vis_line_t(lpc)).value_or(-1_vl))
|
||||||
|
{
|
||||||
assert(lpc >= 0);
|
assert(lpc >= 0);
|
||||||
assert(lpc < LINE_COUNT);
|
assert(lpc < LINE_COUNT);
|
||||||
assert(last_line < lpc);
|
assert(last_line < lpc);
|
||||||
@ -130,7 +131,9 @@ main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
last_line = vis_line_t(10000);
|
last_line = vis_line_t(10000);
|
||||||
for (lpc = LINE_COUNT - 1; lpc != -1; lpc = bv.prev(vis_line_t(lpc))) {
|
for (lpc = LINE_COUNT - 1; lpc != -1;
|
||||||
|
lpc = bv.prev(vis_line_t(lpc)).value_or(-1_vl))
|
||||||
|
{
|
||||||
assert(lpc >= 0);
|
assert(lpc >= 0);
|
||||||
assert(lpc < LINE_COUNT);
|
assert(lpc < LINE_COUNT);
|
||||||
assert(last_line > lpc);
|
assert(last_line > lpc);
|
||||||
|
Loading…
Reference in New Issue
Block a user