uuidset type abandoned; seems it is not actually needed

This commit is contained in:
Alexander Pevzner
2020-10-03 21:42:37 +03:00
parent 14effed058
commit fc94641a46
2 changed files with 0 additions and 160 deletions
-115
View File
@@ -119,120 +119,5 @@ uuid_hash (const char *s)
return uuid_format(buf);
}
/* uuidset represents a set of UUIDs
*/
struct uuidset {
uuid *uuids;
};
/* Create new uuidset
*/
uuidset*
uuidset_new (void)
{
uuidset *set = mem_new(uuidset, 1);
set->uuids = mem_new(uuid, 0);
return set;
}
/* Free uuidset
*/
void
uuidset_free (uuidset *set)
{
mem_free(set->uuids);
mem_free(set);
}
/* Find uuid index within the set. Returns -1, if uuid was not found
*/
static int
uuidset_index (const uuidset *set, uuid uuid)
{
size_t i, len = mem_len(set->uuids);
for (i = 0; i < len; i ++) {
if (uuid_equal(uuid, set->uuids[i])) {
return (int) i;
}
}
return -1;
}
/* Add uuid to uuidset
*/
void
uuidset_add (uuidset *set, uuid uuid)
{
if (uuidset_index(set, uuid) < 0) {
size_t len = mem_len(set->uuids);
set->uuids = mem_resize(set->uuids, len + 1, 0);
set->uuids[len] = uuid;
}
}
/* Del uuid from uuidset
*/
void
uuidset_del (uuidset *set, uuid uuid)
{
int i = uuidset_index(set, uuid);
if (i >= 0) {
size_t len = mem_len(set->uuids);
size_t tail = len - (size_t) i - 1;
if (tail != 0) {
tail *= sizeof(*set->uuids);
memmove(&set->uuids[i], &set->uuids[i + 1], tail);
}
mem_shrink(set->uuids, len - 1);
}
}
/* Check if uuid is in the uuidset
*/
bool
uuidset_lookup (const uuidset *set, uuid uuid)
{
return uuidset_index(set, uuid) >= 0;
}
/* Delete all addresses from the set
*/
void
uuidset_purge (uuidset *set)
{
mem_shrink(set->uuids, 0);
}
/* Merge two sets:
* set += set2
*/
void
uuidset_merge (uuidset *set, const uuidset *set2)
{
size_t i, len = mem_len(set2->uuids);
for (i = 0; i < len; i ++) {
uuidset_add(set, set2->uuids[i]);
}
}
/* Check if two address sets are intersecting
*/
bool
uuidset_is_intersect (const uuidset *set, const uuidset *set2)
{
size_t i, len = mem_len(set2->uuids);
for (i = 0; i < len; i ++) {
if (uuidset_lookup(set2, set->uuids[i])) {
return true;
}
}
return false;
}
/* vim:ts=8:sw=4:et
*/
-45
View File
@@ -792,51 +792,6 @@ uuid_equal (uuid u1, uuid u2)
return !strcmp(u1.text, u2.text);
}
/* uuidset represents a set of UUIDs
*/
typedef struct uuidset uuidset;
/* Create new uuidset
*/
uuidset*
uuidset_new (void);
/* Free uuidset
*/
void
uuidset_free (uuidset *set);
/* Add uuid to uuidset
*/
void
uuidset_add (uuidset *set, uuid uuid);
/* Del uuid from uuidset
*/
void
uuidset_del (uuidset *set, uuid uuid);
/* Check if uuid is in the uuidset
*/
bool
uuidset_lookup (const uuidset *set, uuid uuid);
/* Delete all addresses from the set
*/
void
uuidset_purge (uuidset *set);
/* Merge two sets:
* set += set2
*/
void
uuidset_merge (uuidset *set, const uuidset *set2);
/* Check if two address sets are intersecting
*/
bool
uuidset_is_intersect (const uuidset *set, const uuidset *set2);
/******************** Generic .INI file parser ********************/
/* Types of .INI file records
*/