mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd:Ⓜ️:room: Add sounding iteration.
This commit is contained in:
parent
f044b447e2
commit
c311a69c7b
3 changed files with 35 additions and 10 deletions
|
@ -29,8 +29,10 @@ namespace ircd::m
|
|||
bool for_each_depth_gap(const room &, const depth_range_closure &);
|
||||
bool rfor_each_depth_gap(const room &, const depth_range_closure &);
|
||||
|
||||
std::pair<int64_t, event::idx> surface(const room &); // First missing
|
||||
std::pair<int64_t, event::idx> sounding(const room &); // Last missing
|
||||
bool sounding(const room &, const depth_range_closure &); // Last missing (all)
|
||||
|
||||
std::pair<int64_t, event::idx> surface(const room &); // First missing (one)
|
||||
std::pair<int64_t, event::idx> sounding(const room &); // Last missing (one)
|
||||
std::pair<int64_t, event::idx> twain(const room &);
|
||||
}
|
||||
|
||||
|
|
|
@ -763,6 +763,28 @@ ircd::m::surface(const room &room)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::sounding(const room &room,
|
||||
const depth_range_closure &closure)
|
||||
{
|
||||
bool ret(true);
|
||||
int64_t depth(-1);
|
||||
rfor_each_depth_gap(room, [&depth, &ret, &closure]
|
||||
(const auto &range, const auto &event_idx)
|
||||
{
|
||||
if(depth != -1 && depth != range.second)
|
||||
return false;
|
||||
|
||||
depth = range.second;
|
||||
if(!closure(range, event_idx))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::rfor_each_depth_gap(const room &room,
|
||||
const depth_range_closure &closure)
|
||||
|
|
|
@ -7541,20 +7541,21 @@ console_cmd__room__sounding(opt &out, const string_view &line)
|
|||
m::surface(room)
|
||||
};
|
||||
|
||||
const auto sound
|
||||
{
|
||||
m::sounding(room)
|
||||
};
|
||||
|
||||
const auto twain
|
||||
{
|
||||
m::twain(room)
|
||||
};
|
||||
|
||||
out << "sounding: " << std::setw(8) << sound.first
|
||||
<< " " << m::event_id(sound.second) << " (" << sound.second << ")"
|
||||
m::sounding(room, [&out]
|
||||
(const auto &range, const auto &event_idx)
|
||||
{
|
||||
out << "sounding: " << std::setw(8) << range.second
|
||||
<< " " << m::event_id(event_idx) << " (" << event_idx << ")"
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
out << "twain: " << std::setw(8) << twain.first
|
||||
<< std::endl;
|
||||
|
||||
|
|
Loading…
Reference in a new issue