0
0
Fork 0
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:
Jason Volk 2018-04-11 15:47:51 -07:00
parent 55e4a8fcaf
commit 33ca15e45d
2 changed files with 31 additions and 0 deletions

View file

@ -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);
};

View file

@ -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