mirror of
https://github.com/matrix-construct/construct
synced 2025-01-15 17:16:49 +01:00
ircd:Ⓜ️:user::rooms: Add a count() interface.
This commit is contained in:
parent
55e4a8fcaf
commit
33ca15e45d
2 changed files with 31 additions and 0 deletions
|
@ -97,6 +97,9 @@ struct ircd::m::user::rooms
|
|||
void for_each(const closure_bool &) const;
|
||||
void for_each(const closure &) const;
|
||||
|
||||
size_t count(const string_view &membership) const;
|
||||
size_t count() const;
|
||||
|
||||
rooms(const m::user &user);
|
||||
};
|
||||
|
||||
|
|
28
ircd/m/m.cc
28
ircd/m/m.cc
|
@ -1324,6 +1324,34 @@ ircd::m::user::rooms::rooms(const m::user &user)
|
|||
{
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::user::rooms::count()
|
||||
const
|
||||
{
|
||||
size_t ret{0};
|
||||
for_each([&ret]
|
||||
(const m::room &, const string_view &membership)
|
||||
{
|
||||
++ret;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::user::rooms::count(const string_view &membership)
|
||||
const
|
||||
{
|
||||
size_t ret{0};
|
||||
for_each(membership, [&ret]
|
||||
(const m::room &, const string_view &membership)
|
||||
{
|
||||
++ret;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::user::rooms::for_each(const closure &closure)
|
||||
const
|
||||
|
|
Loading…
Reference in a new issue