|
Data Structures Lerax
v3.0-102-gaf18
Opinionated Data Structures & Algorithms
|
Functions related to various data structures (lists, stacks, queues, trees, hash tables, sets, etc.). More...
Functions | |
| Circle * | circle_create (Point *center, float radius) |
| allocate a new circle on memory based on its parameters | |
| void | circle_free (Circle *c) |
| free memory allocated by the circle c | |
| void | circle_set_center (Circle *c, Point *center) |
| Set the circle center. | |
| void | circle_set_radius (Circle *c, float center) |
| Set the circle radius. | |
| void | circle_set (Circle *c, Point *center, float radius) |
| Set the values of center and radius of structure. | |
| float | circle_get_radius (Circle *c) |
| Get the radius of circle c. | |
| Point * | circle_get_center (Circle *c) |
| Get the center of circle c. | |
| void | circle_get (Circle *c, Point *center, float *radius) |
| Get the its internal attributes through the pointers passed. | |
| int | circle_point_inside (Circle *c, Point *point) |
| Check if the pointer /p point is inside of the circle. | |
| Graph * | graph_create () |
| Creates a new directed graph. | |
| Graph * | graph_undirected_create () |
| Creates a new undirected graph. | |
| void | graph_add_node (Graph *g, int node) |
| Adds a node to the graph. | |
| void | graph_add_edge (Graph *g, int u, int v) |
| Adds an edge to the graph. | |
| void | graph_remove_edge (Graph *g, int u, int v) |
| Removes an edge from the graph. | |
| void | graph_remove_node (Graph *g, int node) |
| Removes a node from the graph. | |
| bool | graph_has_edge (Graph *g, int u, int v) |
| Checks if an edge exists in the graph. | |
| Set * | graph_get_neighbors (Graph *g, int node) |
| Gets the neighbors of a node. | |
| void | graph_free (Graph *g) |
| Frees the memory allocated for the graph. | |
| void | graph_print (Graph *g) |
| Prints the graph. | |
| Iterator * | graph_bfs (Graph *g, int start_node) |
| Performs a Breadth-First Search on a graph. | |
| Iterator * | graph_dfs (Graph *g, int start_node) |
| Performs a Depth-First Search on a graph. | |
| HashTableGen * | hash_table_gen_create (size_t n_buckets) |
| Creates a new generic hash table. | |
| bool | hash_table_gen_empty (HashTableGen *ht) |
| Checks if the hash table is empty. | |
| HashTableGen * | hash_table_gen_copy (HashTableGen *ht) |
| Creates a copy of the hash table. | |
| void | hash_table_gen_put (HashTableGen *ht, int key, void *data) |
| Inserts a key-value pair into the hash table. | |
| void | hash_table_gen_remove (HashTableGen *ht, int key) |
| Removes a key-value pair from the hash table. | |
| void * | hash_table_gen_get (HashTableGen *ht, int key, bool *exists) |
| Gets the value associated with a key. | |
| size_t | hash_table_gen_size (HashTableGen *ht) |
| Gets the size of the hash table. | |
| void | hash_table_gen_print (HashTableGen *ht) |
| Prints the hash table. | |
| ListGen * | hash_table_gen_keys (HashTableGen *ht) |
| Gets the keys of the hash table. | |
| void | hash_table_gen_free (HashTableGen *ht, void(*free_data)(void *)) |
| Frees the memory allocated for the hash table. | |
| HashTable * | hash_table_create (size_t n_buckets) |
| Create a new hash table instance. | |
| bool | hash_table_empty (HashTable *ht) |
| Check if hash table is empty. | |
| HashTable * | hash_table_copy (HashTable *ht) |
| Create a hash table as copy of another. | |
| void | hash_table_put (HashTable *ht, int key, int value) |
| Put a value associated to a key. | |
| void | hash_table_remove (HashTable *ht, int key) |
| Remove a specific value associated with a given key. | |
| int | hash_table_get (HashTable *ht, int key, bool *exists) |
| Get a value in the hash table. | |
| size_t | hash_table_size (HashTable *ht) |
| Get the number of elements in the hash table. | |
| void | hash_table_print (HashTable *ht) |
| Print all buckets of the hash table (one list per line) | |
| void | hash_table_print_items (HashTable *ht) |
| Print items of the hash table. | |
| void | hash_table_print_keys (HashTable *ht) |
| Print keys of the hash table. | |
| List * | hash_table_keys (HashTable *ht) |
| Build a list with the hash table keys. | |
| void | hash_table_free (HashTable *ht) |
| Free memory of hash table and its contents. | |
| ListCircular * | list_circular_create (void) |
| Creates an empty circular list. | |
| int | list_circular_empty (ListCircular *l) |
| Checks if a circular list is empty. | |
| ListCircular * | list_circular_insert (ListCircular *l, int data) |
| Inserts a new element at the beginning of a circular list. | |
| ListCircular * | list_circular_remove (ListCircular *l, int data) |
| Removes an element from a circular list. | |
| ListCircular * | list_circular_search (ListCircular *l, int data) |
| Searches for an element in a circular list. | |
| void | list_circular_print (ListCircular *l) |
| Prints the elements of a circular list to the console, followed by a newline character. | |
| void | list_circular_println (ListCircular *l) |
| Prints the elements of a circular list to the console, followed by a newline character. | |
| void | list_circular_free (ListCircular *l) |
| Frees the memory allocated for a circular list. | |
| ListCircular * | list_circular__new_node (int data) |
| Creates a new node for a circular list. | |
| ListDouble * | list_double_create (void) |
| Creates an empty doubly linked list. | |
| int | list_double_empty (ListDouble *l) |
| Checks if a doubly linked list is empty. | |
| ListDouble * | list_double_insert (ListDouble *l, int data) |
| Inserts a new element at the beginning of a doubly linked list. | |
| ListDouble * | list_double_remove (ListDouble *l, int data) |
| Removes an element from a doubly linked list. | |
| ListDouble * | list_double_search (ListDouble *l, int data) |
| Searches for an element in a doubly linked list. | |
| void | list_double_print (ListDouble *l) |
| Prints the elements of a doubly linked list to the console. | |
| void | list_double_println (ListDouble *l) |
| Prints the elements of a doubly linked list to the console, followed by a newline character. | |
| void | list_double_free (ListDouble *l) |
| Frees the memory allocated for a doubly linked list. | |
| ListDouble * | list_double__new_node (int data) |
| Creates a new node for a doubly linked list. | |
| ListGen * | list_gen_create () |
| Creates a new generic list. | |
| ListGen * | list_gen_copy (ListGen *l) |
| Creates a copy of the list. | |
| bool | list_gen_empty (ListGen *l) |
| Checks if the list is empty. | |
| ListGen * | list_gen_insert (ListGen *l, void *data) |
| Inserts data into the list. | |
| ListGen * | list_gen_insert_with_key (ListGen *l, int key, void *data) |
| Inserts data with a key into the list. | |
| ListGen * | list_gen_search (ListGen *l, void *data) |
| Searches for data in the list. | |
| ListGen * | list_gen_search_by_key (ListGen *l, int key) |
| Searches for a key in the list. | |
| ListGen * | list_gen_remove (ListGen *l, void *data) |
| Removes data from the list. | |
| ListGen * | list_gen_remove_by_key (ListGen *l, int key) |
| Removes a key from the list. | |
| void | list_gen_free (ListGen *l) |
| Frees the memory allocated for the list. | |
| void | list_gen_println (ListGen *l) |
| Prints the list. | |
| ListGen * | list_gen_concat (ListGen *l1, ListGen *l2) |
| Concatenates two lists. | |
| void | list_gen_println_reverse (ListGen *l) |
| Prints the list in reverse order. | |
| List * | list_create (void) |
| create a new list instance | |
| List * | list_insert (List *l, int data) |
| Insert a new element on the beginning of the list. | |
| List * | list_insert_with_key (List *l, int key, int data) |
| Insert a new element on the beginning of the list. | |
| List * | list_append (List *l, int data) |
| Insert a new element on the end of the list. | |
| List * | list_append_with_key (List *l, int key, int data) |
| Insert a new element on the end of the list with key. | |
| List * | list_append_node (List *l, struct ListNode *node) |
| Insert a new node on the end of the list. | |
| List * | list_insert_ord (List *l, int data) |
| Ordered insert of a new element in the list. | |
| List * | list_search (List *l, int data) |
| Search on the list by data and return the node which contains it. | |
| List * | list_search_by_key (List *l, int key) |
| Search on the list by key and return the node which contains it. | |
| void | list_print (List *l) |
| Print the list without a new line. | |
| void | list_println (List *l) |
| Print the list with a new line. | |
| void | list_print_reverse (List *l) |
| Print the list reversed without a new line. | |
| void | list_println_reverse (List *l) |
| Print the list reversed with a new line. | |
| List * | list_remove (List *l, int data) |
| Remove specific element from List. | |
| List * | list_remove_by_key (List *l, int key) |
| Remove specific element from List by a key. | |
| void | list_free (List *l) |
| Free memory of List and its nodes. | |
| int | list_empty (List *l) |
| Verify if the list is empty. | |
| int | list_equal (List *l_x, List *l_y) |
| Check if two lists are equal. | |
| int | list_perfect (List *l) |
| Return the count of perfect numbers on list. | |
| int | list_length (List *l) |
| Return the length of the list. | |
| int | list_less_than (List *l, int n) |
Return the number of numbers less n. | |
| int | list_sum (List *l) |
| Return the sum of numbers on the list. | |
| List * | list_copy (List *l) |
| Create a copy of the list l. | |
| List * | list_concat (List *l_x, List *l_y) |
| Return a concatenation of the two lists as a new list. | |
| List * | list_init (int size_list,...) |
| Create a list based on its variadic arguments. | |
| int | list_last (List *l) |
| Get the data from last element. | |
| int | list_head (List *l) |
| Get the data from the first element. | |
| List * | list_tail (List *l) |
| Get the tail of the list. | |
| int | list_pop_head (List **l) |
| Get and pop the head of the list. | |
| int | list_pop_last (List **l) |
| Get and pop the last element of the list. | |
| void | list_reverse (List **l) |
| Reverse a list (no creating a new) WARNING: side-effects. | |
| int | list__is_perfect_number (int n) |
| Check if a given number is perfect. | |
| List * | list__new_node (int data) |
| Create a new node for the list. | |
| void | matrix_print (Matrix *matrix) |
| Prints the elements of a matrix to the console in a formatted way. | |
| float | matrix_max (Matrix *matrix) |
| Finds the maximum value in a matrix. | |
| Matrix * | matrix_create (int m, int n) |
| Create a new matrix. | |
| void | matrix_free (Matrix *matrix) |
| Free memory of the matrix. | |
| float | matrix_get (Matrix *matrix, int i, int j) |
| Get a value on position (i,j) of the matrix. | |
| void | matrix_set (Matrix *matrix, int i, int j, float v) |
| Set a value on position(i,j) of the matrix. | |
| int | matrix_lines (Matrix *matrix) |
| Get the number of lines of the matrix. | |
| int | matrix_columns (Matrix *matrix) |
| Get the number of columns of the matrix. | |
| Point * | point_create (float x, float y) |
| create a new Point and set x an y | |
| void | point_free (Point *p) |
| free memory for the Point p | |
| void | point_set (Point *p, float x, float y) |
| Set the values of p.x and p.y. | |
| void | point_get (Point *p, float *x, float *y) |
| Get the values of p.x and p.y through the pointers *x and *y. | |
| float | point_get_y (Point *p) |
| Get the y value. | |
| float | point_get_x (Point *p) |
| Get the x value. | |
| void | point_copy (Point *origin, Point *destination) |
| Copy point origin to destination. | |
| float | point_distance (Point *px, Point *py) |
| calculate the euclidean distance between two points | |
| PQueue * | pqueue_create () |
| Creates an empty priority queue. | |
| void | pqueue_insert (PQueue *pq, int x) |
| Inserts an element into the priority queue. | |
| int | pqueue_extract_max (PQueue *pq) |
| Extracts the maximum element from the priority queue. | |
| void | pqueue_increase_keys (PQueue *pq, int k, int v) |
| Increases the key of an element in the priority queue. | |
| int | pqueue_maximum (PQueue *pq) |
| Returns the maximum element in the priority queue without extracting it. | |
| void | pqueue_free (PQueue *pq) |
| Frees the memory allocated for a priority queue. | |
| void | pqueue_print (PQueue *pq) |
| Prints the elements of a priority queue to the console. | |
| void | pqueue_println (PQueue *pq) |
| Prints the elements of a priority queue to the console, followed by a newline character. | |
| Queue * | queue_create (void) |
| Creates an empty queue. | |
| int | queue_empty (Queue *q) |
| Checks if a queue is empty. | |
| void | queue_insert (Queue *q, int data) |
| Inserts an element at the back of a queue. | |
| int | queue_remove (Queue *q) |
| Removes and returns the element at the front of a queue. | |
| void | queue_print (Queue *q) |
| Prints the elements of a queue to the console. | |
| void | queue_println (Queue *q) |
| Prints the elements of a queue to the console, followed by a newline character. | |
| void | queue_free (Queue *q) |
| Frees the memory allocated for a queue. | |
| void | queue_reverse (Queue *q) |
| Reverses the elements of a queue. | |
| int | queue_greater_than (Queue *q, int n) |
| Counts the number of elements in a queue that are greater than a given value. | |
| int | queue_evens (Queue *q) |
| Counts the number of even elements in a queue. | |
| Set * | set_create () |
| Create a new set instance. | |
| Set * | set_init (int set_size,...) |
| Create a new set instance with elements. | |
| 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. | |
| 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_free (Set *set) |
| Free memory of set and its contents. | |
| Stack * | stack_create (void) |
| Creates an empty stack. | |
| int | stack_empty (Stack *s) |
| Checks if a stack is empty. | |
| void | stack_push (Stack *s, int data) |
| Pushes an element onto the top of a stack. | |
| int | stack_pop (Stack *s) |
| Pops an element from the top of a stack. | |
| void | stack_print (Stack *s) |
| Prints the elements of a stack to the console. | |
| void | stack_println (Stack *s) |
| Prints the elements of a stack to the console, followed by a newline character. | |
| void | stack_free (Stack *s) |
| Frees the memory allocated for a stack. | |
| int | stack_top (Stack *s) |
| Returns the element at the top of a stack without removing it. | |
| int | stack_odds (Stack *s) |
| Counts the number of odd elements in a stack. | |
| void | print_ascii_tree (BinaryTree *t) |
| Prints a binary tree to the console as an ASCII art diagram. | |
| AVLTree * | avl_create_node (Type value) |
| Creates a new AVL tree node. | |
| AVLTree * | avl_create (void) |
| Creates an empty AVL tree. | |
| int | avl_empty (AVLTree *t) |
| Checks if an AVL tree is empty. | |
| int | avl_exists (AVLTree *t, Type c) |
| Checks if a value exists in an AVL tree. | |
| AVLTree * | avl_search (AVLTree *t, Type c) |
| Searches for a value in an AVL tree. | |
| void | avl_print (AVLTree *t) |
| Prints the elements of an AVL tree in in-order traversal. | |
| int | avl_height (AVLTree *t) |
| Returns the height of an AVL tree. | |
| AVLTree * | avl_insert (AVLTree *t, Type c) |
| Inserts a value into an AVL tree. | |
| AVLTree * | avl_remove (AVLTree *t, Type c) |
| Removes a value from an AVL tree. | |
| void | avl_free (AVLTree *t) |
| Frees the memory allocated for an AVL tree. | |
| void | avl_posfix (AVLTree *t) |
| Prints the elements of an AVL tree in post-order traversal. | |
| void | avl_prefix (AVLTree *t) |
| Prints the elements of an AVL tree in pre-order traversal. | |
| void | avl_infix (AVLTree *t) |
| Prints the elements of an AVL tree in in-order traversal. | |
| int | avl_nodes (AVLTree *t) |
| Counts the number of nodes in an AVL tree. | |
| int | avl_leafs_primes (AVLTree *t) |
| Counts the number of leaf nodes in an AVL tree that are prime numbers. | |
| int | avl_two_children (AVLTree *t) |
| Counts the number of nodes in an AVL tree that have two children. | |
| int | avl_nodes_equal_height (AVLTree *t) |
| Counts the number of nodes in an AVL tree that have equal branch heights. | |
| int | avl_equals (AVLTree *t1, AVLTree *t2) |
| Compares two AVL trees for equality. | |
| BSTree * | bst_create_node (BSTree *left, BSTree *right, Type value) |
| Creates a new BST node. | |
| BSTree * | bst_create (void) |
| Creates an empty BST. | |
| int | bst_empty (BSTree *t) |
| Checks if a BST is empty. | |
| int | bst_exists (BSTree *t, Type c) |
| Checks if a value exists in a BST. | |
| BSTree * | bst_search (BSTree *t, Type c) |
| Searches for a value in a BST. | |
| void | bst_print (BSTree *t) |
| Prints the elements of a BST in in-order traversal. | |
| int | bst_height (BSTree *t) |
| Returns the height of a BST. | |
| BSTree * | bst_insert (BSTree *t, Type c) |
| Inserts a value into a BST. | |
| BSTree * | bst_remove (BSTree *t, Type c) |
| Removes a value from a BST. | |
| void | bst_free (BSTree *t) |
| Frees the memory allocated for a BST. | |
| void | bst_posfix (BSTree *t) |
| Prints the elements of a BST in post-order traversal. | |
| void | bst_prefix (BSTree *t) |
| Prints the elements of a BST in pre-order traversal. | |
| void | bst_infix (BSTree *t) |
| Prints the elements of a BST in in-order traversal. | |
| int | bst_nodes (BSTree *t) |
| Counts the number of nodes in a BST. | |
| int | bst_leafs_primes (BSTree *t) |
| Counts the number of leaf nodes in a BST that are prime numbers. | |
| int | bst_two_children (BSTree *t) |
| Counts the number of nodes in a BST that have two children. | |
| int | bst_nodes_equal_height (BSTree *t) |
| Counts the number of nodes in a BST that have equal branch heights. | |
| int | bst_equals (BSTree *t1, BSTree *t2) |
| Compares two BSTs for equality. | |
Functions related to various data structures (lists, stacks, queues, trees, hash tables, sets, etc.).
| AVLTree * avl_create | ( | void | ) |
Creates an empty AVL tree.
Creates a new AVL tree node.
| value | The value to store in the node. |
| int avl_empty | ( | AVLTree * | t | ) |
Checks if an AVL tree is empty.
| t | The tree to check. |
Compares two AVL trees for equality.
| t1 | The first tree. |
| t2 | The second tree. |
Checks if a value exists in an AVL tree.
| t | The tree to search in. |
| c | The value to search for. |
| void avl_free | ( | AVLTree * | t | ) |
Frees the memory allocated for an AVL tree.
| t | The tree to free. |
| int avl_height | ( | AVLTree * | t | ) |
Returns the height of an AVL tree.
| t | The tree. |
| void avl_infix | ( | AVLTree * | t | ) |
Prints the elements of an AVL tree in in-order traversal.
| t | The tree to print. |
Inserts a value into an AVL tree.
| t | The tree to insert into. |
| c | The value to insert. |
| int avl_leafs_primes | ( | AVLTree * | t | ) |
Counts the number of leaf nodes in an AVL tree that are prime numbers.
| t | The tree. |
| int avl_nodes | ( | AVLTree * | t | ) |
Counts the number of nodes in an AVL tree.
| t | The tree. |
| int avl_nodes_equal_height | ( | AVLTree * | t | ) |
Counts the number of nodes in an AVL tree that have equal branch heights.
| t | The tree. |
| void avl_posfix | ( | AVLTree * | t | ) |
Prints the elements of an AVL tree in post-order traversal.
| t | The tree to print. |
| void avl_prefix | ( | AVLTree * | t | ) |
Prints the elements of an AVL tree in pre-order traversal.
| t | The tree to print. |
| void avl_print | ( | AVLTree * | t | ) |
Prints the elements of an AVL tree in in-order traversal.
| t | The tree to print. |
Removes a value from an AVL tree.
| t | The tree to remove from. |
| c | The value to remove. |
Searches for a value in an AVL tree.
| t | The tree to search in. |
| c | The value to search for. |
| int avl_two_children | ( | AVLTree * | t | ) |
Counts the number of nodes in an AVL tree that have two children.
| t | The tree. |
| BSTree * bst_create | ( | void | ) |
Creates an empty BST.
Creates a new BST node.
| left | A pointer to the left child. |
| right | A pointer to the right child. |
| value | The value to store in the node. |
| int bst_empty | ( | BSTree * | t | ) |
Checks if a BST is empty.
| t | The tree to check. |
Compares two BSTs for equality.
| t1 | The first tree. |
| t2 | The second tree. |
Checks if a value exists in a BST.
| t | The tree to search in. |
| c | The value to search for. |
| void bst_free | ( | BSTree * | t | ) |
Frees the memory allocated for a BST.
| t | The tree to free. |
| int bst_height | ( | BSTree * | t | ) |
Returns the height of a BST.
| t | The tree. |
| void bst_infix | ( | BSTree * | t | ) |
Prints the elements of a BST in in-order traversal.
| t | The tree to print. |
Inserts a value into a BST.
| t | The tree to insert into. |
| c | The value to insert. |
| int bst_leafs_primes | ( | BSTree * | t | ) |
Counts the number of leaf nodes in a BST that are prime numbers.
| t | The tree. |
| int bst_nodes | ( | BSTree * | t | ) |
Counts the number of nodes in a BST.
| t | The tree. |
| int bst_nodes_equal_height | ( | BSTree * | t | ) |
Counts the number of nodes in a BST that have equal branch heights.
| t | The tree. |
| void bst_posfix | ( | BSTree * | t | ) |
Prints the elements of a BST in post-order traversal.
| t | The tree to print. |
| void bst_prefix | ( | BSTree * | t | ) |
Prints the elements of a BST in pre-order traversal.
| t | The tree to print. |
| void bst_print | ( | BSTree * | t | ) |
Prints the elements of a BST in in-order traversal.
| t | The tree to print. |
Removes a value from a BST.
| t | The tree to remove from. |
| c | The value to remove. |
Searches for a value in a BST.
| t | The tree to search in. |
| c | The value to search for. |
| int bst_two_children | ( | BSTree * | t | ) |
Counts the number of nodes in a BST that have two children.
| t | The tree. |
allocate a new circle on memory based on its parameters
| center | is the center point of the circle |
| radius | is the radius of the circle |
| void circle_free | ( | Circle * | c | ) |
free memory allocated by the circle c
| c | a pointer to Circle structure |
Get the its internal attributes through the pointers passed.
| [in] | c | the desired circle as pointer |
| [out] | center | the point pointer to save the center of c |
| [out] | radius | the radius to save the radius of c |
Get the center of circle c.
| [in] | c | the circle to get the /p center |
| float circle_get_radius | ( | Circle * | c | ) |
Get the radius of circle c.
Check if the pointer /p point is inside of the circle.
| c | is the circle to check |
| point | is the point to check if is inside the /p c |
Set the values of center and radius of structure.
| void graph_add_edge | ( | Graph * | g, |
| int | u, | ||
| int | v ) |
Adds an edge to the graph.
| g | The graph. |
| u | The source node. |
| v | The destination node. |
| void graph_add_node | ( | Graph * | g, |
| int | node ) |
Adds a node to the graph.
| g | The graph. |
| node | The node to be added. |
Performs a Breadth-First Search on a graph.
| g | The graph to traverse. |
| start_node | The node to start the traversal from. |
| Graph * graph_create | ( | ) |
Creates a new directed graph.
Performs a Depth-First Search on a graph.
| g | The graph to traverse. |
| start_node | The node to start the traversal from. |
| void graph_free | ( | Graph * | g | ) |
Frees the memory allocated for the graph.
| g | The graph. |
Gets the neighbors of a node.
| g | The graph. |
| node | The node. |
| bool graph_has_edge | ( | Graph * | g, |
| int | u, | ||
| int | v ) |
Checks if an edge exists in the graph.
| g | The graph. |
| u | The source node. |
| v | The destination node. |
| void graph_print | ( | Graph * | g | ) |
Prints the graph.
| g | The graph. |
| void graph_remove_edge | ( | Graph * | g, |
| int | u, | ||
| int | v ) |
Removes an edge from the graph.
| g | The graph. |
| u | The source node. |
| v | The destination node. |
| void graph_remove_node | ( | Graph * | g, |
| int | node ) |
Removes a node from the graph.
| g | The graph. |
| node | The node to be removed. |
| Graph * graph_undirected_create | ( | ) |
Creates a new undirected graph.
Create a hash table as copy of another.
| ht | hash table to copy |
| HashTable * hash_table_create | ( | size_t | n_buckets | ) |
Create a new hash table instance.
| n_buckets | number of buckets in the hash table |
| bool hash_table_empty | ( | HashTable * | ht | ) |
Check if hash table is empty.
| ht | hash table pointer |
| void hash_table_free | ( | HashTable * | ht | ) |
Free memory of hash table and its contents.
| ht | hash table pointer |
| HashTableGen * hash_table_gen_copy | ( | HashTableGen * | ht | ) |
Creates a copy of the hash table.
| ht | The hash table. |
| HashTableGen * hash_table_gen_create | ( | size_t | n_buckets | ) |
Creates a new generic hash table.
| n_buckets | The number of buckets. |
| bool hash_table_gen_empty | ( | HashTableGen * | ht | ) |
Checks if the hash table is empty.
| ht | The hash table. |
| void hash_table_gen_free | ( | HashTableGen * | ht, |
| void(* | free_data )(void *) ) |
Frees the memory allocated for the hash table.
| ht | The hash table. |
| free_data | A function to free the data. |
| void * hash_table_gen_get | ( | HashTableGen * | ht, |
| int | key, | ||
| bool * | exists ) |
Gets the value associated with a key.
| ht | The hash table. |
| key | The key. |
| exists | A pointer to a boolean that will be set to true if the key exists, false otherwise. |
| ListGen * hash_table_gen_keys | ( | HashTableGen * | ht | ) |
Gets the keys of the hash table.
| ht | The hash table. |
| void hash_table_gen_print | ( | HashTableGen * | ht | ) |
Prints the hash table.
| ht | The hash table. |
| void hash_table_gen_put | ( | HashTableGen * | ht, |
| int | key, | ||
| void * | data ) |
Inserts a key-value pair into the hash table.
| ht | The hash table. |
| key | The key. |
| data | The data. |
| void hash_table_gen_remove | ( | HashTableGen * | ht, |
| int | key ) |
Removes a key-value pair from the hash table.
| ht | The hash table. |
| key | The key. |
| size_t hash_table_gen_size | ( | HashTableGen * | ht | ) |
Gets the size of the hash table.
| ht | The hash table. |
| int hash_table_get | ( | HashTable * | ht, |
| int | key, | ||
| bool * | exists ) |
Get a value in the hash table.
| ht | hash table pointer |
| key | integer key used to locate the bucket |
| exists | bool pointer, set true if found false otherwise; null pointer does nothing |
Build a list with the hash table keys.
| ht | hash table pointer |
| void hash_table_print | ( | HashTable * | ht | ) |
Print all buckets of the hash table (one list per line)
| ht | hash table pointer |
| void hash_table_print_items | ( | HashTable * | ht | ) |
Print items of the hash table.
| ht | hash table pointer |
| void hash_table_print_keys | ( | HashTable * | ht | ) |
Print keys of the hash table.
| ht | hash table pointer |
| void hash_table_put | ( | HashTable * | ht, |
| int | key, | ||
| int | value ) |
Put a value associated to a key.
| ht | hash table pointer |
| key | integer key used to determine the bucket |
| value | integer value to store |
| void hash_table_remove | ( | HashTable * | ht, |
| int | key ) |
Remove a specific value associated with a given key.
| ht | hash table pointer |
| key | integer key used to locate the bucket |
| size_t hash_table_size | ( | HashTable * | ht | ) |
Get the number of elements in the hash table.
| ht | hash table pointer |
| int list__is_perfect_number | ( | int | n | ) |
Check if a given number is perfect.
| List * list__new_node | ( | int | data | ) |
Create a new node for the list.
Insert a new element on the end of the list.
| l | List to insert data on |
| data | integer value to insert on |
Insert a new node on the end of the list.
| l | List to insert data on |
| node | to insert on |
Insert a new element on the end of the list with key.
| l | List to insert data on with key |
| data | integer value to insert on |
| key | integer value to insert on |
| ListCircular * list_circular__new_node | ( | int | data | ) |
Creates a new node for a circular list.
| data | The data to store in the new node. |
| ListCircular * list_circular_create | ( | void | ) |
Creates an empty circular list.
| int list_circular_empty | ( | ListCircular * | l | ) |
Checks if a circular list is empty.
| l | The list to check. |
| void list_circular_free | ( | ListCircular * | l | ) |
Frees the memory allocated for a circular list.
| l | The list to free. |
| ListCircular * list_circular_insert | ( | ListCircular * | l, |
| int | data ) |
Inserts a new element at the beginning of a circular list.
| l | The list to insert into. |
| data | The data to insert. |
| void list_circular_print | ( | ListCircular * | l | ) |
Prints the elements of a circular list to the console, followed by a newline character.
| l | The list to print. |
| void list_circular_println | ( | ListCircular * | l | ) |
Prints the elements of a circular list to the console, followed by a newline character.
| l | The list to print. |
| ListCircular * list_circular_remove | ( | ListCircular * | l, |
| int | data ) |
Removes an element from a circular list.
| l | The list to remove from. |
| data | The data to remove. |
| ListCircular * list_circular_search | ( | ListCircular * | l, |
| int | data ) |
Searches for an element in a circular list.
| l | The list to search in. |
| data | The data to search for. |
Return a concatenation of the two lists as a new list.
| List * list_create | ( | void | ) |
create a new list instance
| ListDouble * list_double__new_node | ( | int | data | ) |
Creates a new node for a doubly linked list.
| data | The data to store in the new node. |
| ListDouble * list_double_create | ( | void | ) |
Creates an empty doubly linked list.
| int list_double_empty | ( | ListDouble * | l | ) |
Checks if a doubly linked list is empty.
| l | The list to check. |
| void list_double_free | ( | ListDouble * | l | ) |
Frees the memory allocated for a doubly linked list.
| l | The list to free. |
| ListDouble * list_double_insert | ( | ListDouble * | l, |
| int | data ) |
Inserts a new element at the beginning of a doubly linked list.
| l | The list to insert into. |
| data | The data to insert. |
| void list_double_print | ( | ListDouble * | l | ) |
Prints the elements of a doubly linked list to the console.
| l | The list to print. |
| void list_double_println | ( | ListDouble * | l | ) |
Prints the elements of a doubly linked list to the console, followed by a newline character.
| l | The list to print. |
| ListDouble * list_double_remove | ( | ListDouble * | l, |
| int | data ) |
Removes an element from a doubly linked list.
| l | The list to remove from. |
| data | The data to remove. |
| ListDouble * list_double_search | ( | ListDouble * | l, |
| int | data ) |
Searches for an element in a doubly linked list.
| l | The list to search in. |
| data | The data to search for. |
| int list_empty | ( | List * | l | ) |
Verify if the list is empty.
Concatenates two lists.
| l1 | The first list. |
| l2 | The second list. |
Creates a copy of the list.
| l | The list. |
| ListGen * list_gen_create | ( | ) |
Creates a new generic list.
| bool list_gen_empty | ( | ListGen * | l | ) |
Checks if the list is empty.
| l | The list. |
| void list_gen_free | ( | ListGen * | l | ) |
Frees the memory allocated for the list.
| l | The list. |
Inserts data into the list.
| l | The list. |
| data | The data. |
Inserts data with a key into the list.
| l | The list. |
| key | The key. |
| data | The data. |
| void list_gen_println | ( | ListGen * | l | ) |
Prints the list.
| l | The list. |
| void list_gen_println_reverse | ( | ListGen * | l | ) |
Prints the list in reverse order.
| l | The list. |
Removes data from the list.
| l | The list. |
| data | The data. |
Removes a key from the list.
| l | The list. |
| key | The key. |
Searches for data in the list.
| l | The list. |
| data | The data. |
Searches for a key in the list.
| l | The list. |
| key | The key. |
| int list_head | ( | List * | l | ) |
Get the data from the first element.
| List * list_init | ( | int | size_list, |
| ... ) |
Create a list based on its variadic arguments.
| size_list | number of paramaters passed to the function |
Insert a new element on the beginning of the list.
| l | List to insert data on |
| data | integer value to insert on |
Ordered insert of a new element in the list.
| l | List to insert data on |
| data | integer value to insert on |
Insert a new element on the beginning of the list.
| l | List to insert data and key on |
| data | integer value to insert on |
| key | integer value to insert on |
| int list_last | ( | List * | l | ) |
Get the data from last element.
| int list_length | ( | List * | l | ) |
Return the length of the list.
| int list_less_than | ( | List * | l, |
| int | n ) |
Return the number of numbers less n.
| int list_perfect | ( | List * | l | ) |
Return the count of perfect numbers on list.
| int list_pop_head | ( | List ** | l | ) |
Get and pop the head of the list.
| int list_pop_last | ( | List ** | l | ) |
Get and pop the last element of the list.
| void list_print | ( | List * | l | ) |
Print the list without a new line.
| l | the list to print |
| void list_print_reverse | ( | List * | l | ) |
Print the list reversed without a new line.
| l | the list to print |
| void list_println | ( | List * | l | ) |
Print the list with a new line.
| l | the list to print |
| void list_println_reverse | ( | List * | l | ) |
Print the list reversed with a new line.
| l | the list to print |
| void list_reverse | ( | List ** | l | ) |
Reverse a list (no creating a new) WARNING: side-effects.
Search on the list by data and return the node which contains it.
| l | List to insert data on |
| data | integer value to search on |
Search on the list by key and return the node which contains it.
| l | List to search key |
| key | integer value to search |
| int list_sum | ( | List * | l | ) |
Return the sum of numbers on the list.
| int matrix_columns | ( | Matrix * | matrix | ) |
Get the number of columns of the matrix.
| matrix | the matrix pointer |
| Matrix * matrix_create | ( | int | m, |
| int | n ) |
Create a new matrix.
| m | means number of lines |
| n | means number of columns |
| void matrix_free | ( | Matrix * | matrix | ) |
Free memory of the matrix.
| matrix | the matrix pointer itself |
| float matrix_get | ( | Matrix * | matrix, |
| int | i, | ||
| int | j ) |
Get a value on position (i,j) of the matrix.
| matrix | the matrix pointer |
| i | the line index |
| j | the column index |
| int matrix_lines | ( | Matrix * | matrix | ) |
Get the number of lines of the matrix.
| matrix | the matrix pointer |
| float matrix_max | ( | Matrix * | matrix | ) |
Finds the maximum value in a matrix.
| matrix | The matrix to search. |
| void matrix_print | ( | Matrix * | matrix | ) |
Prints the elements of a matrix to the console in a formatted way.
Copyright 2017-2025 Manoel Vilela
Author: Manoel Vilela
Contact: manoel_vilela@engineer.com
Organization: UFC
| matrix | The matrix to print. |
| void matrix_set | ( | Matrix * | matrix, |
| int | i, | ||
| int | j, | ||
| float | v ) |
Set a value on position(i,j) of the matrix.
| matrix | the matrix pointer |
| i | the line index |
| j | the column index |
| v | the value the set on (i,j) |
| Point * point_create | ( | float | x, |
| float | y ) |
create a new Point and set x an y
calculate the euclidean distance between two points
| void point_get | ( | Point * | p, |
| float * | x, | ||
| float * | y ) |
Get the values of p.x and p.y through the pointers *x and *y.
| float point_get_x | ( | Point * | p | ) |
Get the x value.
| float point_get_y | ( | Point * | p | ) |
Get the y value.
| PQueue * pqueue_create | ( | ) |
Creates an empty priority queue.
| int pqueue_extract_max | ( | PQueue * | pq | ) |
Extracts the maximum element from the priority queue.
| pq | The priority queue to extract from. |
| void pqueue_free | ( | PQueue * | pq | ) |
Frees the memory allocated for a priority queue.
| pq | The priority queue to free. |
| void pqueue_increase_keys | ( | PQueue * | pq, |
| int | k, | ||
| int | v ) |
Increases the key of an element in the priority queue.
| pq | The priority queue. |
| k | The index of the element to increase. |
| v | The new value of the element. |
| void pqueue_insert | ( | PQueue * | pq, |
| int | x ) |
Inserts an element into the priority queue.
| pq | The priority queue to insert into. |
| x | The element to insert. |
| int pqueue_maximum | ( | PQueue * | pq | ) |
Returns the maximum element in the priority queue without extracting it.
| pq | The priority queue. |
| void pqueue_print | ( | PQueue * | pq | ) |
Prints the elements of a priority queue to the console.
| pq | The priority queue to print. |
| void pqueue_println | ( | PQueue * | pq | ) |
Prints the elements of a priority queue to the console, followed by a newline character.
| pq | The priority queue to print. |
| void print_ascii_tree | ( | BinaryTree * | t | ) |
Prints a binary tree to the console as an ASCII art diagram.
Copyright 2017-2025 Manoel Vilela
Author: Manoel Vilela
Contact: manoel_vilela@engineer.com
Organization: UFC
| t | The binary tree to print. |
| Queue * queue_create | ( | void | ) |
Creates an empty queue.
| int queue_empty | ( | Queue * | q | ) |
Checks if a queue is empty.
| q | The queue to check. |
| int queue_evens | ( | Queue * | q | ) |
Counts the number of even elements in a queue.
| q | The queue to search. |
| void queue_free | ( | Queue * | q | ) |
Frees the memory allocated for a queue.
| q | The queue to free. |
| int queue_greater_than | ( | Queue * | q, |
| int | n ) |
Counts the number of elements in a queue that are greater than a given value.
| q | The queue to search. |
| n | The value to compare against. |
| void queue_insert | ( | Queue * | q, |
| int | data ) |
Inserts an element at the back of a queue.
| q | The queue to insert into. |
| data | The data to insert. |
| void queue_print | ( | Queue * | q | ) |
Prints the elements of a queue to the console.
| q | The queue to print. |
| void queue_println | ( | Queue * | q | ) |
Prints the elements of a queue to the console, followed by a newline character.
| q | The queue to print. |
| int queue_remove | ( | Queue * | q | ) |
Removes and returns the element at the front of a queue.
| q | The queue to remove from. |
| void queue_reverse | ( | Queue * | q | ) |
Reverses the elements of a queue.
| q | The queue to reverse. |
| void set_add | ( | Set * | set, |
| int | element ) |
Put a value associated to a key.
| set | pointer |
| element | integer to add in the set |
| bool set_contains | ( | Set * | set, |
| int | element ) |
Get a value in the set.
| set | pointer |
| element | integer used to check if exists in the set |
Create a set as copy of another.
| set | to copy |
| Set * set_create | ( | ) |
Create a new set instance.
Difference of set A and B.
| set_a | set A |
| set_b | set B |
Check if set A and B are equals.
| set_a | set A |
| set_b | set B |
| void set_free | ( | Set * | set | ) |
Free memory of set and its contents.
| set | pointer |
| Set * set_init | ( | int | set_size, |
| ... ) |
Create a new set instance with elements.
| set_size | number of elements in initialization |
Intersection of set A and B.
| set_a | set A |
| set_b | set B |
| void set_print | ( | Set * | set | ) |
Print all elements of the set.
| set | pointer |
| void set_remove | ( | Set * | set, |
| int | element ) |
Remove a element.
| set | pointer |
| element | integer used to remove |
Check if set A is a subset of set B.
| set_a | set A |
| set_b | set B |
| Stack * stack_create | ( | void | ) |
Creates an empty stack.
| int stack_empty | ( | Stack * | s | ) |
Checks if a stack is empty.
| s | The stack to check. |
| void stack_free | ( | Stack * | s | ) |
Frees the memory allocated for a stack.
| s | The stack to free. |
| int stack_odds | ( | Stack * | s | ) |
Counts the number of odd elements in a stack.
| s | The stack to search. |
| int stack_pop | ( | Stack * | s | ) |
Pops an element from the top of a stack.
| s | The stack to pop from. |
| void stack_print | ( | Stack * | s | ) |
Prints the elements of a stack to the console.
| s | The stack to print. |
| void stack_println | ( | Stack * | s | ) |
Prints the elements of a stack to the console, followed by a newline character.
| s | The stack to print. |
| void stack_push | ( | Stack * | s, |
| int | data ) |
Pushes an element onto the top of a stack.
| s | The stack to push onto. |
| data | The data to push. |
| int stack_top | ( | Stack * | s | ) |
Returns the element at the top of a stack without removing it.
| s | The stack to peek at. |