mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:Ⓜ️:room::type: Add directional iteration deduced by range.
This commit is contained in:
parent
206afc25b0
commit
a8b5912e98
1 changed files with 11 additions and 3 deletions
|
@ -59,10 +59,15 @@ bool
|
|||
ircd::m::room::type::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
const bool desc
|
||||
{
|
||||
range.second < 0 || uint64_t(range.second) < range.first
|
||||
};
|
||||
|
||||
char buf[dbs::ROOM_TYPE_KEY_MAX_SIZE];
|
||||
const string_view &key
|
||||
{
|
||||
dbs::room_type_key(buf, room.room_id, _type, range.first, -1UL)
|
||||
dbs::room_type_key(buf, room.room_id, _type, range.first, desc? -1UL: 0UL)
|
||||
};
|
||||
|
||||
auto it
|
||||
|
@ -70,14 +75,17 @@ const
|
|||
dbs::room_type.begin(key)
|
||||
};
|
||||
|
||||
for(; it; ++it)
|
||||
for(; it; desc? ++it: --it)
|
||||
{
|
||||
const auto &[_type, depth, event_idx]
|
||||
{
|
||||
dbs::room_type_key(it->first)
|
||||
};
|
||||
|
||||
if(int64_t(depth) <= range.second)
|
||||
if(desc && int64_t(depth) <= range.second)
|
||||
break;
|
||||
|
||||
if(!desc && int64_t(depth) >= range.second)
|
||||
break;
|
||||
|
||||
if(this->_type && !prefixing && this->_type != _type)
|
||||
|
|
Loading…
Reference in a new issue