diff options
author | Carl Worth <cworth@cworth.org> | 2013-10-25 13:38:38 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-10-25 15:29:09 -0700 |
commit | 5594ed57413bf0117c592cf8edc8c9363b98a578 (patch) | |
tree | eb91118aaee8acb55d2356f0047aa9f4f7d5ecd0 /int-set.c | |
parent | 9dd53079a431768b76431fa632a5ea086d0c54e9 (diff) |
Add set_contains and int_set_contains functions.
These are convenience functions on top of set_search and
int_set_search. With a set, containment is often the most important
notion of interest, and it helps to be able to query this without
needing to declare a local struct set_entry*.
v2: Whitespace consistency (changes by anholt)
Diffstat (limited to 'int-set.c')
-rw-r--r-- | int-set.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -137,6 +137,18 @@ int_set_destroy(struct int_set *set) free(set); } +/* Does the set contain an entry with the given value. + */ +bool +int_set_contains(struct int_set *set, uint32_t value) +{ + struct int_set_entry *entry; + + entry = int_set_search(set, value); + + return entry != NULL; +} + /** * Finds a set entry with the given value * |