Data Structures Lerax  v3.0-101-gb1f7
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
set.h File Reference
#include <stddef.h>
#include <stdbool.h>
#include "../list/single/list.h"
#include "../iterator/iterator.h"

Go to the source code of this file.

Typedefs

typedef struct Set Set
 A basic implementation of a Set.

Functions

Setset_create ()
 Create a new set instance.
Setset_init (int set_size,...)
 Create a new set instance with elements.
Setset_copy (Set *set)
 Create a set as copy of another.
void set_add (Set *set, int element)
 Put a value associated to a key.
bool set_subset (Set *set_a, Set *set_b)
 Check if set A is a subset of set B.
Setset_intersection (Set *set_a, Set *set_b)
 Intersection of set A and B.
Setset_union (Set *set_a, Set *set_b)
 Union of set A and B.
Setset_difference (Set *set_a, Set *set_b)
 Difference of set A and B.
bool set_equal (Set *set_a, Set *set_b)
 Check if set A and B are equals.
void set_remove (Set *set, int element)
 Remove a element.
bool set_contains (Set *set, int element)
 Get a value in the set.
void set_print (Set *set)
 Print all elements of the set.
void set_free (Set *set)
 Free memory of set and its contents.
Iteratorset_iterator (Set *s)
 Creates an iterator for the set.
Setset_from_iterator (Iterator *s)
 Creates a set from an iterator.

Typedef Documentation

◆ Set

typedef struct Set Set

A basic implementation of a Set.


    Copyrigset 2025 Manoel Vilela

    Author: Manoel Vilela
   Contact: manoel_vilela@engineer.com

Organization: ITA


This implementation uses a hash table to store the elements, which allows for efficient insertion, deletion, and membership testing.

Function Documentation

◆ set_from_iterator()

Set * set_from_iterator ( Iterator * s)

Creates a set from an iterator.

Parameters
sThe iterator to create the set from.
Returns
A pointer to the new set.

◆ set_iterator()

Iterator * set_iterator ( Set * s)

Creates an iterator for the set.

Parameters
sThe set to iterate over.
Returns
A pointer to the new iterator.