|
Data Structures Lerax
1.1.0
Opinionated Data Structures & Algorithms
|
#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 | |
| Set * | set_create () |
| Create a new set instance. | |
| Set * | set_init (int set_size,...) |
| Create a new set instance with elements. | |
| int | set_size (Set *set) |
| Get a the size of the set. | |
| Set * | set_copy (Set *set) |
| Create a set as copy of another. | |
| void | set_add (Set *set, int element) |
| Put a value associated to a key. | |
| void | set_add_with_value (Set *set, int element, int value) |
| Add an element to the set with a custom value. | |
| int | set_get_value (Set *set, int element) |
| Get the value of an element in the set. | |
| bool | set_subset (Set *set_a, Set *set_b) |
| Check if set A is a subset of set B. | |
| Set * | set_intersection (Set *set_a, Set *set_b) |
| Intersection of set A and B. | |
| Set * | set_union (Set *set_a, Set *set_b) |
| Union of set A and B. | |
| Set * | set_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_print_items (Set *set) |
| Print all elements with its inner value. | |
| void | set_free (Set *set) |
| Free memory of set and its contents. | |
| Iterator * | set_iterator (Set *s) |
| Creates an iterator for the key elements of set. | |
| Iterator * | set_iterator_items (Set *s) |
| Creates an iterator for (key, value) of the set. The elements are a List*. | |
| Set * | set_from_iterator (Iterator *s) |
| Creates a set from an iterator. | |
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.
Creates a set from an iterator.
| s | The iterator to create the set from. |
Creates an iterator for the key elements of set.
| s | The set to iterate over. |