basic/ordered-set: add functions to operate on OrderedSets of strings
This commit is contained in:
@@ -45,3 +45,21 @@ int ordered_set_put_strdupv(OrderedSet *s, char **l) {
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int ordered_set_put_string_set(OrderedSet *s, OrderedSet *l) {
|
||||
int n = 0, r;
|
||||
Iterator i;
|
||||
char *p;
|
||||
|
||||
/* Like ordered_set_put_strv, but for an OrderedSet of strings */
|
||||
|
||||
ORDERED_SET_FOREACH(p, l, i) {
|
||||
r = ordered_set_put_strdup(s, p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
n += r;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,14 @@ static inline void* ordered_set_steal_first(OrderedSet *s) {
|
||||
return ordered_hashmap_steal_first((OrderedHashmap*) s);
|
||||
}
|
||||
|
||||
static inline char **ordered_set_get_strv(OrderedSet *s) {
|
||||
return internal_hashmap_get_strv(HASHMAP_BASE((OrderedHashmap*) s));
|
||||
}
|
||||
|
||||
int ordered_set_consume(OrderedSet *s, void *p);
|
||||
int ordered_set_put_strdup(OrderedSet *s, const char *p);
|
||||
int ordered_set_put_strdupv(OrderedSet *s, char **l);
|
||||
int ordered_set_put_string_set(OrderedSet *s, OrderedSet *l);
|
||||
|
||||
#define ORDERED_SET_FOREACH(e, s, i) \
|
||||
for ((i) = ITERATOR_FIRST; ordered_set_iterate((s), &(i), (void**)&(e)); )
|
||||
|
||||
Reference in New Issue
Block a user