Data Structures Lerax  v3.0-102-gaf18
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
Data Structure Methods

Functions related to various data structures (lists, stacks, queues, trees, hash tables, sets, etc.). More...

Functions

Circlecircle_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.
Pointcircle_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.
Graphgraph_create ()
 Creates a new directed graph.
Graphgraph_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.
Setgraph_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.
Iteratorgraph_bfs (Graph *g, int start_node)
 Performs a Breadth-First Search on a graph.
Iteratorgraph_dfs (Graph *g, int start_node)
 Performs a Depth-First Search on a graph.
HashTableGenhash_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.
HashTableGenhash_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.
ListGenhash_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.
HashTablehash_table_create (size_t n_buckets)
 Create a new hash table instance.
bool hash_table_empty (HashTable *ht)
 Check if hash table is empty.
HashTablehash_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.
Listhash_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.
ListCircularlist_circular_create (void)
 Creates an empty circular list.
int list_circular_empty (ListCircular *l)
 Checks if a circular list is empty.
ListCircularlist_circular_insert (ListCircular *l, int data)
 Inserts a new element at the beginning of a circular list.
ListCircularlist_circular_remove (ListCircular *l, int data)
 Removes an element from a circular list.
ListCircularlist_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.
ListCircularlist_circular__new_node (int data)
 Creates a new node for a circular list.
ListDoublelist_double_create (void)
 Creates an empty doubly linked list.
int list_double_empty (ListDouble *l)
 Checks if a doubly linked list is empty.
ListDoublelist_double_insert (ListDouble *l, int data)
 Inserts a new element at the beginning of a doubly linked list.
ListDoublelist_double_remove (ListDouble *l, int data)
 Removes an element from a doubly linked list.
ListDoublelist_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.
ListDoublelist_double__new_node (int data)
 Creates a new node for a doubly linked list.
ListGenlist_gen_create ()
 Creates a new generic list.
ListGenlist_gen_copy (ListGen *l)
 Creates a copy of the list.
bool list_gen_empty (ListGen *l)
 Checks if the list is empty.
ListGenlist_gen_insert (ListGen *l, void *data)
 Inserts data into the list.
ListGenlist_gen_insert_with_key (ListGen *l, int key, void *data)
 Inserts data with a key into the list.
ListGenlist_gen_search (ListGen *l, void *data)
 Searches for data in the list.
ListGenlist_gen_search_by_key (ListGen *l, int key)
 Searches for a key in the list.
ListGenlist_gen_remove (ListGen *l, void *data)
 Removes data from the list.
ListGenlist_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.
ListGenlist_gen_concat (ListGen *l1, ListGen *l2)
 Concatenates two lists.
void list_gen_println_reverse (ListGen *l)
 Prints the list in reverse order.
Listlist_create (void)
 create a new list instance
Listlist_insert (List *l, int data)
 Insert a new element on the beginning of the list.
Listlist_insert_with_key (List *l, int key, int data)
 Insert a new element on the beginning of the list.
Listlist_append (List *l, int data)
 Insert a new element on the end of the list.
Listlist_append_with_key (List *l, int key, int data)
 Insert a new element on the end of the list with key.
Listlist_append_node (List *l, struct ListNode *node)
 Insert a new node on the end of the list.
Listlist_insert_ord (List *l, int data)
 Ordered insert of a new element in the list.
Listlist_search (List *l, int data)
 Search on the list by data and return the node which contains it.
Listlist_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.
Listlist_remove (List *l, int data)
 Remove specific element from List.
Listlist_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.
Listlist_copy (List *l)
 Create a copy of the list l.
Listlist_concat (List *l_x, List *l_y)
 Return a concatenation of the two lists as a new list.
Listlist_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.
Listlist_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.
Listlist__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.
Matrixmatrix_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.
Pointpoint_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
PQueuepqueue_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.
Queuequeue_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.
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.
Stackstack_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.
AVLTreeavl_create_node (Type value)
 Creates a new AVL tree node.
AVLTreeavl_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.
AVLTreeavl_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.
AVLTreeavl_insert (AVLTree *t, Type c)
 Inserts a value into an AVL tree.
AVLTreeavl_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.
BSTreebst_create_node (BSTree *left, BSTree *right, Type value)
 Creates a new BST node.
BSTreebst_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.
BSTreebst_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.
BSTreebst_insert (BSTree *t, Type c)
 Inserts a value into a BST.
BSTreebst_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.

Detailed Description

Functions related to various data structures (lists, stacks, queues, trees, hash tables, sets, etc.).

Function Documentation

◆ avl_create()

AVLTree * avl_create ( void )

Creates an empty AVL tree.

Returns
A null pointer, representing an empty tree.

◆ avl_create_node()

AVLTree * avl_create_node ( Type value)

Creates a new AVL tree node.

Parameters
valueThe value to store in the node.
Returns
A pointer to the new node.

◆ avl_empty()

int avl_empty ( AVLTree * t)

Checks if an AVL tree is empty.

Parameters
tThe tree to check.
Returns
1 if the tree is empty, 0 otherwise.

◆ avl_equals()

int avl_equals ( AVLTree * t1,
AVLTree * t2 )

Compares two AVL trees for equality.

Parameters
t1The first tree.
t2The second tree.
Returns
1 if the trees are equal, 0 otherwise.

◆ avl_exists()

int avl_exists ( AVLTree * t,
Type c )

Checks if a value exists in an AVL tree.

Parameters
tThe tree to search in.
cThe value to search for.
Returns
1 if the value exists, 0 otherwise.

◆ avl_free()

void avl_free ( AVLTree * t)

Frees the memory allocated for an AVL tree.

Parameters
tThe tree to free.

◆ avl_height()

int avl_height ( AVLTree * t)

Returns the height of an AVL tree.

Parameters
tThe tree.
Returns
The height of the tree.

◆ avl_infix()

void avl_infix ( AVLTree * t)

Prints the elements of an AVL tree in in-order traversal.

Parameters
tThe tree to print.

◆ avl_insert()

AVLTree * avl_insert ( AVLTree * t,
Type c )

Inserts a value into an AVL tree.

Parameters
tThe tree to insert into.
cThe value to insert.
Returns
The updated tree.

◆ avl_leafs_primes()

int avl_leafs_primes ( AVLTree * t)

Counts the number of leaf nodes in an AVL tree that are prime numbers.

Parameters
tThe tree.
Returns
The number of prime leaf nodes.

◆ avl_nodes()

int avl_nodes ( AVLTree * t)

Counts the number of nodes in an AVL tree.

Parameters
tThe tree.
Returns
The number of nodes.

◆ avl_nodes_equal_height()

int avl_nodes_equal_height ( AVLTree * t)

Counts the number of nodes in an AVL tree that have equal branch heights.

Parameters
tThe tree.
Returns
The number of nodes with equal branch heights.

◆ avl_posfix()

void avl_posfix ( AVLTree * t)

Prints the elements of an AVL tree in post-order traversal.

Parameters
tThe tree to print.

◆ avl_prefix()

void avl_prefix ( AVLTree * t)

Prints the elements of an AVL tree in pre-order traversal.

Parameters
tThe tree to print.

◆ avl_print()

void avl_print ( AVLTree * t)

Prints the elements of an AVL tree in in-order traversal.

Parameters
tThe tree to print.

◆ avl_remove()

AVLTree * avl_remove ( AVLTree * t,
Type c )

Removes a value from an AVL tree.

Parameters
tThe tree to remove from.
cThe value to remove.
Returns
The updated tree.

◆ avl_search()

AVLTree * avl_search ( AVLTree * t,
Type c )

Searches for a value in an AVL tree.

Parameters
tThe tree to search in.
cThe value to search for.
Returns
A pointer to the node containing the value, or a null pointer if the value is not found.

◆ avl_two_children()

int avl_two_children ( AVLTree * t)

Counts the number of nodes in an AVL tree that have two children.

Parameters
tThe tree.
Returns
The number of nodes with two children.

◆ bst_create()

BSTree * bst_create ( void )

Creates an empty BST.

Returns
A null pointer, representing an empty tree.

◆ bst_create_node()

BSTree * bst_create_node ( BSTree * left,
BSTree * right,
Type value )

Creates a new BST node.

Parameters
leftA pointer to the left child.
rightA pointer to the right child.
valueThe value to store in the node.
Returns
A pointer to the new node.

◆ bst_empty()

int bst_empty ( BSTree * t)

Checks if a BST is empty.

Parameters
tThe tree to check.
Returns
1 if the tree is empty, 0 otherwise.

◆ bst_equals()

int bst_equals ( BSTree * t1,
BSTree * t2 )

Compares two BSTs for equality.

Parameters
t1The first tree.
t2The second tree.
Returns
1 if the trees are equal, 0 otherwise.

◆ bst_exists()

int bst_exists ( BSTree * t,
Type c )

Checks if a value exists in a BST.

Parameters
tThe tree to search in.
cThe value to search for.
Returns
1 if the value exists, 0 otherwise.

◆ bst_free()

void bst_free ( BSTree * t)

Frees the memory allocated for a BST.

Parameters
tThe tree to free.

◆ bst_height()

int bst_height ( BSTree * t)

Returns the height of a BST.

Parameters
tThe tree.
Returns
The height of the tree.

◆ bst_infix()

void bst_infix ( BSTree * t)

Prints the elements of a BST in in-order traversal.

Parameters
tThe tree to print.

◆ bst_insert()

BSTree * bst_insert ( BSTree * t,
Type c )

Inserts a value into a BST.

Parameters
tThe tree to insert into.
cThe value to insert.
Returns
The updated tree.

◆ bst_leafs_primes()

int bst_leafs_primes ( BSTree * t)

Counts the number of leaf nodes in a BST that are prime numbers.

Parameters
tThe tree.
Returns
The number of prime leaf nodes.

◆ bst_nodes()

int bst_nodes ( BSTree * t)

Counts the number of nodes in a BST.

Parameters
tThe tree.
Returns
The number of nodes.

◆ bst_nodes_equal_height()

int bst_nodes_equal_height ( BSTree * t)

Counts the number of nodes in a BST that have equal branch heights.

Parameters
tThe tree.
Returns
The number of nodes with equal branch heights.

◆ bst_posfix()

void bst_posfix ( BSTree * t)

Prints the elements of a BST in post-order traversal.

Parameters
tThe tree to print.

◆ bst_prefix()

void bst_prefix ( BSTree * t)

Prints the elements of a BST in pre-order traversal.

Parameters
tThe tree to print.

◆ bst_print()

void bst_print ( BSTree * t)

Prints the elements of a BST in in-order traversal.

Parameters
tThe tree to print.

◆ bst_remove()

BSTree * bst_remove ( BSTree * t,
Type c )

Removes a value from a BST.

Parameters
tThe tree to remove from.
cThe value to remove.
Returns
The updated tree.

◆ bst_search()

BSTree * bst_search ( BSTree * t,
Type c )

Searches for a value in a BST.

Parameters
tThe tree to search in.
cThe value to search for.
Returns
A pointer to the node containing the value, or a null pointer if the value is not found.

◆ bst_two_children()

int bst_two_children ( BSTree * t)

Counts the number of nodes in a BST that have two children.

Parameters
tThe tree.
Returns
The number of nodes with two children.

◆ circle_create()

Circle * circle_create ( Point * center,
float radius )

allocate a new circle on memory based on its parameters

Parameters
centeris the center point of the circle
radiusis the radius of the circle
Returns
the address of the allocated circle

◆ circle_free()

void circle_free ( Circle * c)

free memory allocated by the circle c

Parameters
ca pointer to Circle structure

◆ circle_get()

void circle_get ( Circle * c,
Point * center,
float * radius )

Get the its internal attributes through the pointers passed.

Parameters
[in]cthe desired circle as pointer
[out]centerthe point pointer to save the center of c
[out]radiusthe radius to save the radius of c

◆ circle_get_center()

Point * circle_get_center ( Circle * c)

Get the center of circle c.

Parameters
[in]cthe circle to get the /p center

◆ circle_get_radius()

float circle_get_radius ( Circle * c)

Get the radius of circle c.

◆ circle_point_inside()

int circle_point_inside ( Circle * c,
Point * point )

Check if the pointer /p point is inside of the circle.

Parameters
cis the circle to check
pointis the point to check if is inside the /p c
Returns
1 if inside of the circle, otherwise 0

◆ circle_set()

void circle_set ( Circle * c,
Point * center,
float radius )

Set the values of center and radius of structure.

◆ circle_set_center()

void circle_set_center ( Circle * c,
Point * center )

Set the circle center.

◆ circle_set_radius()

void circle_set_radius ( Circle * c,
float center )

Set the circle radius.

◆ graph_add_edge()

void graph_add_edge ( Graph * g,
int u,
int v )

Adds an edge to the graph.

Parameters
gThe graph.
uThe source node.
vThe destination node.

◆ graph_add_node()

void graph_add_node ( Graph * g,
int node )

Adds a node to the graph.

Parameters
gThe graph.
nodeThe node to be added.

◆ graph_bfs()

Iterator * graph_bfs ( Graph * g,
int start_node )

Performs a Breadth-First Search on a graph.

Parameters
gThe graph to traverse.
start_nodeThe node to start the traversal from.
Returns
A node iterator

◆ graph_create()

Graph * graph_create ( )

Creates a new directed graph.

Returns
A pointer to the new graph.

◆ graph_dfs()

Iterator * graph_dfs ( Graph * g,
int start_node )

Performs a Depth-First Search on a graph.

Parameters
gThe graph to traverse.
start_nodeThe node to start the traversal from.
Returns
A node iterator

◆ graph_free()

void graph_free ( Graph * g)

Frees the memory allocated for the graph.

Parameters
gThe graph.

◆ graph_get_neighbors()

Set * graph_get_neighbors ( Graph * g,
int node )

Gets the neighbors of a node.

Parameters
gThe graph.
nodeThe node.
Returns
A set containing the neighbors of the node.

◆ graph_has_edge()

bool graph_has_edge ( Graph * g,
int u,
int v )

Checks if an edge exists in the graph.

Parameters
gThe graph.
uThe source node.
vThe destination node.
Returns
True if the edge exists, false otherwise.

◆ graph_print()

void graph_print ( Graph * g)

Prints the graph.

Parameters
gThe graph.

◆ graph_remove_edge()

void graph_remove_edge ( Graph * g,
int u,
int v )

Removes an edge from the graph.

Parameters
gThe graph.
uThe source node.
vThe destination node.

◆ graph_remove_node()

void graph_remove_node ( Graph * g,
int node )

Removes a node from the graph.

Parameters
gThe graph.
nodeThe node to be removed.

◆ graph_undirected_create()

Graph * graph_undirected_create ( )

Creates a new undirected graph.

Returns
A pointer to the new graph.

◆ hash_table_copy()

HashTable * hash_table_copy ( HashTable * ht)

Create a hash table as copy of another.

Parameters
hthash table to copy
Returns
pointer to the newly created hash table

◆ hash_table_create()

HashTable * hash_table_create ( size_t n_buckets)

Create a new hash table instance.

Parameters
n_bucketsnumber of buckets in the hash table
Returns
pointer to the newly created hash table

◆ hash_table_empty()

bool hash_table_empty ( HashTable * ht)

Check if hash table is empty.

Parameters
hthash table pointer
Returns
true if empty, false otherwise

◆ hash_table_free()

void hash_table_free ( HashTable * ht)

Free memory of hash table and its contents.

Parameters
hthash table pointer

◆ hash_table_gen_copy()

HashTableGen * hash_table_gen_copy ( HashTableGen * ht)

Creates a copy of the hash table.

Parameters
htThe hash table.
Returns
A pointer to the new hash table.

◆ hash_table_gen_create()

HashTableGen * hash_table_gen_create ( size_t n_buckets)

Creates a new generic hash table.

Parameters
n_bucketsThe number of buckets.
Returns
A pointer to the new hash table.

◆ hash_table_gen_empty()

bool hash_table_gen_empty ( HashTableGen * ht)

Checks if the hash table is empty.

Parameters
htThe hash table.
Returns
True if the hash table is empty, false otherwise.

◆ hash_table_gen_free()

void hash_table_gen_free ( HashTableGen * ht,
void(* free_data )(void *) )

Frees the memory allocated for the hash table.

Parameters
htThe hash table.
free_dataA function to free the data.

◆ hash_table_gen_get()

void * hash_table_gen_get ( HashTableGen * ht,
int key,
bool * exists )

Gets the value associated with a key.

Parameters
htThe hash table.
keyThe key.
existsA pointer to a boolean that will be set to true if the key exists, false otherwise.
Returns
The value associated with the key.

◆ hash_table_gen_keys()

ListGen * hash_table_gen_keys ( HashTableGen * ht)

Gets the keys of the hash table.

Parameters
htThe hash table.
Returns
A list of the keys.

◆ hash_table_gen_print()

void hash_table_gen_print ( HashTableGen * ht)

Prints the hash table.

Parameters
htThe hash table.

◆ hash_table_gen_put()

void hash_table_gen_put ( HashTableGen * ht,
int key,
void * data )

Inserts a key-value pair into the hash table.

Parameters
htThe hash table.
keyThe key.
dataThe data.

◆ hash_table_gen_remove()

void hash_table_gen_remove ( HashTableGen * ht,
int key )

Removes a key-value pair from the hash table.

Parameters
htThe hash table.
keyThe key.

◆ hash_table_gen_size()

size_t hash_table_gen_size ( HashTableGen * ht)

Gets the size of the hash table.

Parameters
htThe hash table.
Returns
The size of the hash table.

◆ hash_table_get()

int hash_table_get ( HashTable * ht,
int key,
bool * exists )

Get a value in the hash table.

Parameters
hthash table pointer
keyinteger key used to locate the bucket
existsbool pointer, set true if found false otherwise; null pointer does nothing

◆ hash_table_keys()

List * hash_table_keys ( HashTable * ht)

Build a list with the hash table keys.

Parameters
hthash table pointer

◆ hash_table_print()

void hash_table_print ( HashTable * ht)

Print all buckets of the hash table (one list per line)

Parameters
hthash table pointer

◆ hash_table_print_items()

void hash_table_print_items ( HashTable * ht)

Print items of the hash table.

Parameters
hthash table pointer

◆ hash_table_print_keys()

void hash_table_print_keys ( HashTable * ht)

Print keys of the hash table.

Parameters
hthash table pointer

◆ hash_table_put()

void hash_table_put ( HashTable * ht,
int key,
int value )

Put a value associated to a key.

Parameters
hthash table pointer
keyinteger key used to determine the bucket
valueinteger value to store

◆ hash_table_remove()

void hash_table_remove ( HashTable * ht,
int key )

Remove a specific value associated with a given key.

Parameters
hthash table pointer
keyinteger key used to locate the bucket

◆ hash_table_size()

size_t hash_table_size ( HashTable * ht)

Get the number of elements in the hash table.

Parameters
hthash table pointer
Returns
the number of elements inside of the hash table

◆ list__is_perfect_number()

int list__is_perfect_number ( int n)

Check if a given number is perfect.

◆ list__new_node()

List * list__new_node ( int data)

Create a new node for the list.

◆ list_append()

List * list_append ( List * l,
int data )

Insert a new element on the end of the list.

Parameters
lList to insert data on
datainteger value to insert on
Returns
the updated list

◆ list_append_node()

List * list_append_node ( List * l,
struct ListNode * node )

Insert a new node on the end of the list.

Parameters
lList to insert data on
nodeto insert on
Returns
the updated list

◆ list_append_with_key()

List * list_append_with_key ( List * l,
int key,
int data )

Insert a new element on the end of the list with key.

Parameters
lList to insert data on with key
datainteger value to insert on
keyinteger value to insert on
Returns
the updated list

◆ list_circular__new_node()

ListCircular * list_circular__new_node ( int data)

Creates a new node for a circular list.

Parameters
dataThe data to store in the new node.
Returns
A pointer to the new node.

◆ list_circular_create()

ListCircular * list_circular_create ( void )

Creates an empty circular list.

Returns
A null pointer, representing an empty list.

◆ list_circular_empty()

int list_circular_empty ( ListCircular * l)

Checks if a circular list is empty.

Parameters
lThe list to check.
Returns
1 if the list is empty, 0 otherwise.

◆ list_circular_free()

void list_circular_free ( ListCircular * l)

Frees the memory allocated for a circular list.

Parameters
lThe list to free.

◆ list_circular_insert()

ListCircular * list_circular_insert ( ListCircular * l,
int data )

Inserts a new element at the beginning of a circular list.

Parameters
lThe list to insert into.
dataThe data to insert.
Returns
The updated list.

◆ list_circular_print()

void list_circular_print ( ListCircular * l)

Prints the elements of a circular list to the console, followed by a newline character.

Parameters
lThe list to print.

◆ list_circular_println()

void list_circular_println ( ListCircular * l)

Prints the elements of a circular list to the console, followed by a newline character.

Parameters
lThe list to print.

◆ list_circular_remove()

ListCircular * list_circular_remove ( ListCircular * l,
int data )

Removes an element from a circular list.

Parameters
lThe list to remove from.
dataThe data to remove.
Returns
The updated list.

◆ list_circular_search()

ListCircular * list_circular_search ( ListCircular * l,
int data )

Searches for an element in a circular list.

Parameters
lThe list to search in.
dataThe data to search for.
Returns
A pointer to the node containing the data, or a null pointer if the data is not found.

◆ list_concat()

List * list_concat ( List * l_x,
List * l_y )

Return a concatenation of the two lists as a new list.

◆ list_copy()

List * list_copy ( List * l)

Create a copy of the list l.

◆ list_create()

List * list_create ( void )

create a new list instance

◆ list_double__new_node()

ListDouble * list_double__new_node ( int data)

Creates a new node for a doubly linked list.

Parameters
dataThe data to store in the new node.
Returns
A pointer to the new node.

◆ list_double_create()

ListDouble * list_double_create ( void )

Creates an empty doubly linked list.

Returns
A null pointer, representing an empty list.

◆ list_double_empty()

int list_double_empty ( ListDouble * l)

Checks if a doubly linked list is empty.

Parameters
lThe list to check.
Returns
1 if the list is empty, 0 otherwise.

◆ list_double_free()

void list_double_free ( ListDouble * l)

Frees the memory allocated for a doubly linked list.

Parameters
lThe list to free.

◆ list_double_insert()

ListDouble * list_double_insert ( ListDouble * l,
int data )

Inserts a new element at the beginning of a doubly linked list.

Parameters
lThe list to insert into.
dataThe data to insert.
Returns
The updated list.

◆ list_double_print()

void list_double_print ( ListDouble * l)

Prints the elements of a doubly linked list to the console.

Parameters
lThe list to print.

◆ list_double_println()

void list_double_println ( ListDouble * l)

Prints the elements of a doubly linked list to the console, followed by a newline character.

Parameters
lThe list to print.

◆ list_double_remove()

ListDouble * list_double_remove ( ListDouble * l,
int data )

Removes an element from a doubly linked list.

Parameters
lThe list to remove from.
dataThe data to remove.
Returns
The updated list.

◆ list_double_search()

ListDouble * list_double_search ( ListDouble * l,
int data )

Searches for an element in a doubly linked list.

Parameters
lThe list to search in.
dataThe data to search for.
Returns
A pointer to the node containing the data, or a null pointer if the data is not found.

◆ list_empty()

int list_empty ( List * l)

Verify if the list is empty.

Returns
1 if empty and 0 if is not

◆ list_equal()

int list_equal ( List * l_x,
List * l_y )

Check if two lists are equal.

◆ list_free()

void list_free ( List * l)

Free memory of List and its nodes.

◆ list_gen_concat()

ListGen * list_gen_concat ( ListGen * l1,
ListGen * l2 )

Concatenates two lists.

Parameters
l1The first list.
l2The second list.
Returns
A pointer to the new list.

◆ list_gen_copy()

ListGen * list_gen_copy ( ListGen * l)

Creates a copy of the list.

Parameters
lThe list.
Returns
A pointer to the new list.

◆ list_gen_create()

ListGen * list_gen_create ( )

Creates a new generic list.

Returns
A pointer to the new list.

◆ list_gen_empty()

bool list_gen_empty ( ListGen * l)

Checks if the list is empty.

Parameters
lThe list.
Returns
True if the list is empty, false otherwise.

◆ list_gen_free()

void list_gen_free ( ListGen * l)

Frees the memory allocated for the list.

Parameters
lThe list.

◆ list_gen_insert()

ListGen * list_gen_insert ( ListGen * l,
void * data )

Inserts data into the list.

Parameters
lThe list.
dataThe data.
Returns
A pointer to the new list.

◆ list_gen_insert_with_key()

ListGen * list_gen_insert_with_key ( ListGen * l,
int key,
void * data )

Inserts data with a key into the list.

Parameters
lThe list.
keyThe key.
dataThe data.
Returns
A pointer to the new list.

◆ list_gen_println()

void list_gen_println ( ListGen * l)

Prints the list.

Parameters
lThe list.

◆ list_gen_println_reverse()

void list_gen_println_reverse ( ListGen * l)

Prints the list in reverse order.

Parameters
lThe list.

◆ list_gen_remove()

ListGen * list_gen_remove ( ListGen * l,
void * data )

Removes data from the list.

Parameters
lThe list.
dataThe data.
Returns
A pointer to the new list.

◆ list_gen_remove_by_key()

ListGen * list_gen_remove_by_key ( ListGen * l,
int key )

Removes a key from the list.

Parameters
lThe list.
keyThe key.
Returns
A pointer to the new list.

◆ list_gen_search()

ListGen * list_gen_search ( ListGen * l,
void * data )

Searches for data in the list.

Parameters
lThe list.
dataThe data.
Returns
A pointer to the list node containing the data, or NULL if not found.

◆ list_gen_search_by_key()

ListGen * list_gen_search_by_key ( ListGen * l,
int key )

Searches for a key in the list.

Parameters
lThe list.
keyThe key.
Returns
A pointer to the list node containing the key, or NULL if not found.

◆ list_head()

int list_head ( List * l)

Get the data from the first element.

◆ list_init()

List * list_init ( int size_list,
... )

Create a list based on its variadic arguments.

Parameters
size_listnumber of paramaters passed to the function

◆ list_insert()

List * list_insert ( List * l,
int data )

Insert a new element on the beginning of the list.

Parameters
lList to insert data on
datainteger value to insert on
Returns
the updated list

◆ list_insert_ord()

List * list_insert_ord ( List * l,
int data )

Ordered insert of a new element in the list.

Parameters
lList to insert data on
datainteger value to insert on
Returns
the updated list

◆ list_insert_with_key()

List * list_insert_with_key ( List * l,
int key,
int data )

Insert a new element on the beginning of the list.

Parameters
lList to insert data and key on
datainteger value to insert on
keyinteger value to insert on
Returns
the updated list

◆ list_last()

int list_last ( List * l)

Get the data from last element.

◆ list_length()

int list_length ( List * l)

Return the length of the list.

◆ list_less_than()

int list_less_than ( List * l,
int n )

Return the number of numbers less n.

◆ list_perfect()

int list_perfect ( List * l)

Return the count of perfect numbers on list.

◆ list_pop_head()

int list_pop_head ( List ** l)

Get and pop the head of the list.

◆ list_pop_last()

int list_pop_last ( List ** l)

Get and pop the last element of the list.

◆ list_print()

void list_print ( List * l)

Print the list without a new line.

Parameters
lthe list to print

◆ list_print_reverse()

void list_print_reverse ( List * l)

Print the list reversed without a new line.

Parameters
lthe list to print

◆ list_println()

void list_println ( List * l)

Print the list with a new line.

Parameters
lthe list to print

◆ list_println_reverse()

void list_println_reverse ( List * l)

Print the list reversed with a new line.

Parameters
lthe list to print

◆ list_remove()

List * list_remove ( List * l,
int data )

Remove specific element from List.

Parameters
lList to remove data on
datainteger value to remove
Returns
new list without the node which contains data

◆ list_remove_by_key()

List * list_remove_by_key ( List * l,
int key )

Remove specific element from List by a key.

Parameters
lList to remove with key
keyinteger value to remove
Returns
new list without the node which contains key

◆ list_reverse()

void list_reverse ( List ** l)

Reverse a list (no creating a new) WARNING: side-effects.

◆ list_search()

List * list_search ( List * l,
int data )

Search on the list by data and return the node which contains it.

Parameters
lList to insert data on
datainteger value to search on
Returns
the node to return it

◆ list_search_by_key()

List * list_search_by_key ( List * l,
int key )

Search on the list by key and return the node which contains it.

Parameters
lList to search key
keyinteger value to search
Returns
the node to return it

◆ list_sum()

int list_sum ( List * l)

Return the sum of numbers on the list.

◆ list_tail()

List * list_tail ( List * l)

Get the tail of the list.

◆ matrix_columns()

int matrix_columns ( Matrix * matrix)

Get the number of columns of the matrix.

Parameters
matrixthe matrix pointer
Returns
the number of columns

◆ matrix_create()

Matrix * matrix_create ( int m,
int n )

Create a new matrix.

Parameters
mmeans number of lines
nmeans number of columns
Returns
the address of the created matrix

◆ matrix_free()

void matrix_free ( Matrix * matrix)

Free memory of the matrix.

Parameters
matrixthe matrix pointer itself

◆ matrix_get()

float matrix_get ( Matrix * matrix,
int i,
int j )

Get a value on position (i,j) of the matrix.

Parameters
matrixthe matrix pointer
ithe line index
jthe column index
Returns
the value on (i,j) as float

◆ matrix_lines()

int matrix_lines ( Matrix * matrix)

Get the number of lines of the matrix.

Parameters
matrixthe matrix pointer
Returns
the number of lines

◆ matrix_max()

float matrix_max ( Matrix * matrix)

Finds the maximum value in a matrix.

Parameters
matrixThe matrix to search.
Returns
The maximum value in the matrix.

◆ matrix_print()

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


Parameters
matrixThe matrix to print.

◆ matrix_set()

void matrix_set ( Matrix * matrix,
int i,
int j,
float v )

Set a value on position(i,j) of the matrix.

Parameters
matrixthe matrix pointer
ithe line index
jthe column index
vthe value the set on (i,j)

◆ point_copy()

void point_copy ( Point * origin,
Point * destination )

Copy point origin to destination.

◆ point_create()

Point * point_create ( float x,
float y )

create a new Point and set x an y

Returns
the address of the allocated point

◆ point_distance()

float point_distance ( Point * px,
Point * py )

calculate the euclidean distance between two points

Returns
the distance of *px and *py as a float number

◆ point_free()

void point_free ( Point * p)

free memory for the Point p

Parameters
pPoint to be free

◆ point_get()

void point_get ( Point * p,
float * x,
float * y )

Get the values of p.x and p.y through the pointers *x and *y.

◆ point_get_x()

float point_get_x ( Point * p)

Get the x value.

◆ point_get_y()

float point_get_y ( Point * p)

Get the y value.

◆ point_set()

void point_set ( Point * p,
float x,
float y )

Set the values of p.x and p.y.

◆ pqueue_create()

PQueue * pqueue_create ( )

Creates an empty priority queue.

Returns
A pointer to the new priority queue.

◆ pqueue_extract_max()

int pqueue_extract_max ( PQueue * pq)

Extracts the maximum element from the priority queue.

Parameters
pqThe priority queue to extract from.
Returns
The maximum element.

◆ pqueue_free()

void pqueue_free ( PQueue * pq)

Frees the memory allocated for a priority queue.

Parameters
pqThe priority queue to free.

◆ pqueue_increase_keys()

void pqueue_increase_keys ( PQueue * pq,
int k,
int v )

Increases the key of an element in the priority queue.

Parameters
pqThe priority queue.
kThe index of the element to increase.
vThe new value of the element.

◆ pqueue_insert()

void pqueue_insert ( PQueue * pq,
int x )

Inserts an element into the priority queue.

Parameters
pqThe priority queue to insert into.
xThe element to insert.

◆ pqueue_maximum()

int pqueue_maximum ( PQueue * pq)

Returns the maximum element in the priority queue without extracting it.

Parameters
pqThe priority queue.
Returns
The maximum element.

◆ pqueue_print()

void pqueue_print ( PQueue * pq)

Prints the elements of a priority queue to the console.

Parameters
pqThe priority queue to print.

◆ pqueue_println()

void pqueue_println ( PQueue * pq)

Prints the elements of a priority queue to the console, followed by a newline character.

Parameters
pqThe priority queue to print.

◆ print_ascii_tree()

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


Parameters
tThe binary tree to print.

◆ queue_create()

Queue * queue_create ( void )

Creates an empty queue.

Returns
A pointer to the new queue.

◆ queue_empty()

int queue_empty ( Queue * q)

Checks if a queue is empty.

Parameters
qThe queue to check.
Returns
1 if the queue is empty, 0 otherwise.

◆ queue_evens()

int queue_evens ( Queue * q)

Counts the number of even elements in a queue.

Parameters
qThe queue to search.
Returns
The number of even elements.

◆ queue_free()

void queue_free ( Queue * q)

Frees the memory allocated for a queue.

Parameters
qThe queue to free.

◆ queue_greater_than()

int queue_greater_than ( Queue * q,
int n )

Counts the number of elements in a queue that are greater than a given value.

Parameters
qThe queue to search.
nThe value to compare against.
Returns
The number of elements greater than n.

◆ queue_insert()

void queue_insert ( Queue * q,
int data )

Inserts an element at the back of a queue.

Parameters
qThe queue to insert into.
dataThe data to insert.

◆ queue_print()

void queue_print ( Queue * q)

Prints the elements of a queue to the console.

Parameters
qThe queue to print.

◆ queue_println()

void queue_println ( Queue * q)

Prints the elements of a queue to the console, followed by a newline character.

Parameters
qThe queue to print.

◆ queue_remove()

int queue_remove ( Queue * q)

Removes and returns the element at the front of a queue.

Parameters
qThe queue to remove from.
Returns
The element at the front of the queue.

◆ queue_reverse()

void queue_reverse ( Queue * q)

Reverses the elements of a queue.

Parameters
qThe queue to reverse.

◆ set_add()

void set_add ( Set * set,
int element )

Put a value associated to a key.

Parameters
setpointer
elementinteger to add in the set

◆ set_contains()

bool set_contains ( Set * set,
int element )

Get a value in the set.

Parameters
setpointer
elementinteger used to check if exists in the set

◆ set_copy()

Set * set_copy ( Set * set)

Create a set as copy of another.

Parameters
setto copy
Returns
pointer to the newly created set

◆ set_create()

Set * set_create ( )

Create a new set instance.

Returns
pointer to the newly created set

◆ set_difference()

Set * set_difference ( Set * set_a,
Set * set_b )

Difference of set A and B.

Parameters
set_aset A
set_bset B

◆ set_equal()

bool set_equal ( Set * set_a,
Set * set_b )

Check if set A and B are equals.

Parameters
set_aset A
set_bset B
Returns
boolean if set A and B are equals

◆ set_free()

void set_free ( Set * set)

Free memory of set and its contents.

Parameters
setpointer

◆ set_init()

Set * set_init ( int set_size,
... )

Create a new set instance with elements.

Parameters
set_sizenumber of elements in initialization
Returns
pointer to the newly created set

◆ set_intersection()

Set * set_intersection ( Set * set_a,
Set * set_b )

Intersection of set A and B.

Parameters
set_aset A
set_bset B

◆ set_print()

void set_print ( Set * set)

Print all elements of the set.

Parameters
setpointer

◆ set_remove()

void set_remove ( Set * set,
int element )

Remove a element.

Parameters
setpointer
elementinteger used to remove

◆ set_subset()

bool set_subset ( Set * set_a,
Set * set_b )

Check if set A is a subset of set B.

Parameters
set_aset A
set_bset B

◆ set_union()

Set * set_union ( Set * set_a,
Set * set_b )

Union of set A and B.

Parameters
set_aset A
set_bset B

◆ stack_create()

Stack * stack_create ( void )

Creates an empty stack.

Returns
A pointer to the new stack.

◆ stack_empty()

int stack_empty ( Stack * s)

Checks if a stack is empty.

Parameters
sThe stack to check.
Returns
1 if the stack is empty, 0 otherwise.

◆ stack_free()

void stack_free ( Stack * s)

Frees the memory allocated for a stack.

Parameters
sThe stack to free.

◆ stack_odds()

int stack_odds ( Stack * s)

Counts the number of odd elements in a stack.

Parameters
sThe stack to search.
Returns
The number of odd elements.

◆ stack_pop()

int stack_pop ( Stack * s)

Pops an element from the top of a stack.

Parameters
sThe stack to pop from.
Returns
The popped element.

◆ stack_print()

void stack_print ( Stack * s)

Prints the elements of a stack to the console.

Parameters
sThe stack to print.

◆ stack_println()

void stack_println ( Stack * s)

Prints the elements of a stack to the console, followed by a newline character.

Parameters
sThe stack to print.

◆ stack_push()

void stack_push ( Stack * s,
int data )

Pushes an element onto the top of a stack.

Parameters
sThe stack to push onto.
dataThe data to push.

◆ stack_top()

int stack_top ( Stack * s)

Returns the element at the top of a stack without removing it.

Parameters
sThe stack to peek at.
Returns
The element at the top of the stack.