From abe4e31d05f7bda9d2e67b2f72484ca5f39eee3c Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 6 Jan 2021 19:58:25 -0800 Subject: [PATCH] Added hashset_to_array --- hashset.c | 12 ++++++++++++ include/cyclone/hashset.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/hashset.c b/hashset.c index d0dcc7af..b6ac8d9c 100644 --- a/hashset.c +++ b/hashset.c @@ -143,3 +143,15 @@ int hashset_is_member(hashset_t set, void *item) } return 0; } + +void hashset_to_array(hashset_t set, void *items) +{ + for (unsigned int hs = 0, a = 0; hs ; set->capacity; hs++) { + size_t value = (size_t)item; + if (value != 0 && value != 1) { + items[a] = set->items[hs]; + a++; + } + } +} + diff --git a/include/cyclone/hashset.h b/include/cyclone/hashset.h index fd336181..28787ace 100644 --- a/include/cyclone/hashset.h +++ b/include/cyclone/hashset.h @@ -66,6 +66,8 @@ extern "C" { */ int hashset_is_member(hashset_t set, void *item); + void hashset_to_array(hashset_t set, void *items); + #ifdef __cplusplus } #endif