data_structures
Data Structures | Typedefs | Functions
union_find.h File Reference
#include <errno.h>
#include <sys/types.h>
#include "types.h"
#include "utils.h"
+ Include dependency graph for union_find.h:

Go to the source code of this file.

Data Structures

struct  s_union_find
 Weighted quick-union by rank with path compression by halving. More...
 

Typedefs

typedef struct s_union_find t_union_find
 

Functions

t_union_findunion_find_new (size_t size)
 Initializes a new union-find data structure of the specified size. More...
 
void union_find_union (t_union_find *uf, size_t p, size_t q)
 Merges the set containing element p with the set containing element q. More...
 
size_t union_find_count (const t_union_find *uf)
 Returns the number of disconnected sets. More...
 
size_t union_find_size (const t_union_find *uf)
 Returns the number of elements in this union-find. More...
 
void union_find_delete (t_union_find *uf)
 Deletes the union-find and frees all memory taken by its contents, or does nothing if the argument is NULL. More...
 
size_t union_find_find (const t_union_find *uf, size_t p)
 Returns the canonical element of the set containing the specified element. More...
 

Function Documentation

◆ union_find_count()

size_t union_find_count ( const t_union_find uf)

Returns the number of disconnected sets.

Returns
The number of disconnected sets

Definition at line 16 of file union_find_count.c.

◆ union_find_delete()

void union_find_delete ( t_union_find uf)

Deletes the union-find and frees all memory taken by its contents, or does nothing if the argument is NULL.

Definition at line 16 of file union_find_delete.c.

◆ union_find_find()

size_t union_find_find ( const t_union_find uf,
size_t  p 
)

Returns the canonical element of the set containing the specified element.

Parameters
pAn element
Returns
The canonical element of the set containing the specified element

Definition at line 16 of file union_find_find.c.

◆ union_find_new()

t_union_find* union_find_new ( size_t  size)

Initializes a new union-find data structure of the specified size.

Returns
The new union-find data structure

Definition at line 16 of file union_find_new.c.

◆ union_find_size()

size_t union_find_size ( const t_union_find uf)

Returns the number of elements in this union-find.

Returns
The number of elements in this union-find.

Definition at line 16 of file union_find_size.c.

◆ union_find_union()

void union_find_union ( t_union_find uf,
size_t  p,
size_t  q 
)

Merges the set containing element p with the set containing element q.

Parameters
pon element
qthe other element

Definition at line 16 of file union_find_union.c.