summaryrefslogtreecommitdiff
path: root/int-set.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2013-10-25 13:38:38 -0700
committerEric Anholt <eric@anholt.net>2013-10-25 15:29:09 -0700
commit5594ed57413bf0117c592cf8edc8c9363b98a578 (patch)
treeeb91118aaee8acb55d2356f0047aa9f4f7d5ecd0 /int-set.c
parent9dd53079a431768b76431fa632a5ea086d0c54e9 (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.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/int-set.c b/int-set.c
index c58ee5d..853bb9e 100644
--- a/int-set.c
+++ b/int-set.c
@@ -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
*