diff --git a/tools/qfcc/include/set.h b/tools/qfcc/include/set.h index 01d17b4a6..65af7bdc8 100644 --- a/tools/qfcc/include/set.h +++ b/tools/qfcc/include/set.h @@ -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); diff --git a/tools/qfcc/source/set.c b/tools/qfcc/source/set.c index 9ff61ca86..57279bf71 100644 --- a/tools/qfcc/source/set.c +++ b/tools/qfcc/source/set.c @@ -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) {