As Estruturas de Dados em Listas
Por: CAINAN TRAVIZANUTTO E SILVA • 10/9/2022 • Relatório de pesquisa • 3.861 Palavras (16 Páginas) • 107 Visualizações
/* ----------------------------------------------
Cainan Travizanutto && Gabriel Maestre - 2022;
#ifndef data_structs_assignment_done
#define project_1_data_structures_lab
#endif
------------------ QUICK INFO -------------------
This is not meant to be used in production, only for study purpose
All static functions are meant to be used internally, thus the _prefix format
If user calls function with wrong parameters the function will either return and don't display any errors
or behave improperly
Functions
{
create list: takes a pointer to list pointer and data to be inserted
split: takes two pointers to list pointers, the original list and the one to be splited to, and the data of the new first node of the latter list
insert: takes a list pointer, a bool, witch if true inserts in order else after a specific node (last argument), and data to be inserted
remove: takes a list pointer and a bool, which if true removes all nodes, else a specific one
print: it prints ¯\_(ツ)_/¯
}
-------------------- SUMMARY --------------------
64 -> Structs
84 -> Prototypes of Functions
119 -> Implementation of Simple Linked List
119-127 Create a Simply List
129-149 Split Simply List
151-196 Insert Simply List
198-240 Remove Simply List
242-250 Print Simply List
252 -> Implementation of Head Simply Linked List
252-270 Create a Head Simply List
272-295 Split Head Simply List
297-309 Insert Head Simply List
311-325 Remove Head Simply List
327-332 Print Head Simply List
334 -> Implementation of Circular Linked List
334-343 Create a Circular List
345-373 Split Circular List
375-423 Insert Circular List
425-473 Remove Circular List
475-485 Print Circular List
487 -> Implementation of Doubly Linked List
487-496 Create a Doubly List
498-519 Split Doubly List
521-571 Insert Doubly List
573-609 Remove Doubly List
611-619 Print Doubly List
624 -> License
*/
#ifndef _PROJECT1_H
#define _PROJECT1_H
#ifndef _BOOL
typedef enum{ false, true } bool;
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
// Holds a data data of int type and a struct pointer to the next element in the list
typedef struct simple_node {
int data;
struct simple_node *next;
} node;
// Holds list size and a struct pointer to first element of the list
typedef struct head_node {
int size;
struct simple_node *first;
} h_node;
// Holds a data data of int type and two struct pointers, one to the next element in the list and one to the prior
typedef struct doubly_node {
int data;
struct doubly_node *next;
struct doubly_node *prev;
} d_node;
//------------------------------ SIMPLE LINKED LIST ------------------------------//
void node_create_list(int data, node** list);
void node_split_list(node** list_split_from, node** list_split_to, int node_pos_data);
void node_insert(node *list, int data, bool in_order, ...);
void node_remove(node **list, bool delete_all, ...);
void node_print_list(node *list);
//------------------------- SIMPLE LINKED LIST WITH HEAD -------------------------//
void h_node_create_list(int data, h_node **list);
void h_node_split_list(h_node** head_split_from, h_node** head_split_to, int node_pos_data);
void h_node_insert(h_node *head, int data, bool in_order, ...);
void h_node_remove(h_node **head, bool delete_all, ...);
void h_node_print_list(h_node *head);
//----------------------------- CIRCULAR LINKED LIST -----------------------------//
void c_node_create_list(node **list, int data);
void c_node_split_list(node** list_split_from,
...