mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Add set_size ().
Return the number of members in the set.
This commit is contained in:
parent
8567508963
commit
388b6e6e8f
2 changed files with 13 additions and 0 deletions
|
@ -69,6 +69,7 @@ int set_is_intersecting (const set_t *s1, const set_t *s2);
|
|||
int set_is_equivalent (const set_t *s1, const set_t *s2);
|
||||
int set_is_subset (const set_t *set, const set_t *sub);
|
||||
int set_is_member (const set_t *set, unsigned x);
|
||||
unsigned set_size (const set_t *set);
|
||||
setstate_t *set_first (const set_t *set);
|
||||
setstate_t *set_next (setstate_t *setstate);
|
||||
const char *set_as_string (const set_t *set);
|
||||
|
|
|
@ -269,6 +269,18 @@ set_is_member (const set_t *set, unsigned x)
|
|||
return (set->map[x / BITS] & (1 << (x % BITS))) != 0;
|
||||
}
|
||||
|
||||
unsigned
|
||||
set_size (const set_t *set)
|
||||
{
|
||||
unsigned count = 0;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < set->size; i++)
|
||||
if (set_is_member (set, i))
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
setstate_t *
|
||||
set_first (const set_t *set)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue