feat: remove list in ufd because it's a linked list

This commit is contained in:
Nemo D'ACREMONT 2025-04-25 08:41:28 +02:00
parent d709f4eb6a
commit da2ed43135
No known key found for this signature in database
GPG Key ID: 85F245EC3BB1E022
2 changed files with 7 additions and 10 deletions

View File

@ -5,10 +5,10 @@
void ufd__init(struct ufd_t* ufd, struct context_entry_t* thread)
{
TAILQ_INIT(&ufd->children);
ufd->thread = thread;
ufd->repr = ufd,
ufd->parent = NULL;
ufd->child = NULL;
}
@ -19,7 +19,7 @@ void ufd__join(struct ufd_t* th1, struct ufd_t* th2)
if (a != b)
{
a->parent = b;
a->parent = th2;
a->repr = b;
}
}
@ -38,9 +38,9 @@ struct ufd_t* ufd__find(struct ufd_t* th)
void ufd__delete(struct ufd_t* th)
{
struct ufd_t* child;
TAILQ_FOREACH(child, &th->children, link) {
child->parent = NULL;
child->repr = child;
if (th->child != NULL)
{
th->child->parent = th->child;
th->child->repr = th->child;
}
}

View File

@ -2,15 +2,12 @@
#define _UNION_FIND_H_
#include <sys/queue.h>
TAILQ_HEAD(ufd_children_t, ufd_t);
// union find delete data structure
struct ufd_t {
struct ufd_t* parent;
struct ufd_t* repr;
struct ufd_t* child;
struct context_entry_t* thread;
struct ufd_children_t children;
TAILQ_ENTRY(ufd_t) link;
};