1
0
Fork 0

Added attributes to single linked list, to warn of discarded values and null values.

This commit is contained in:
Wael Karram 2024-02-18 22:39:17 +02:00
parent 2006b3ae1b
commit 33eeea878d
Signed by: wael
GPG Key ID: 3B356038CCB10808
1 changed files with 26 additions and 0 deletions

View File

@ -51,55 +51,81 @@ typedef struct linked_list {
} linked_list_t;
/* This function initializes a new linked list. */
[[nodiscard]]
linked_list_t* initialize_single_linked_list();
/* This function appends a node to the given linked list. */
[[gnu::nonnull(1,2)]]
void append_node_single_linked_list(linked_list_t *list, node_t *node);
/* This function prepends a node to the given linked list. */
[[gnu::nonnull(1,2)]]
void prepend_node_single_linked_list(linked_list_t *list, node_t *node);
/* This function creates and appends a node to the given linked list. */
[[gnu::nonnull(1)]] [[nodiscard]]
int append_node_data_single_linked_list(linked_list_t *list, void *data);
/* This function creates and prepends a node to the given linked list. */
[[gnu::nonnull(1)]] [[nodiscard]]
int prepend_node_data_single_linked_list(linked_list_t *list, void *data);
/* This function inserts a node at the ith place. */
[[gnu::nonnull(1,2)]]
void add_node_i_single_linked_list(linked_list_t *list, node_t *node, size_t i);
/* This function creates and inserts a node at the ith place. */
[[gnu::nonnull(1)]] [[nodiscard]]
int add_node_data_i_single_linked_list(linked_list_t *list, void *data, size_t i);
/* This function reads the data at the ith node. */
[[gnu::nonnull(1)]] [[nodiscard]]
void* read_node_i_single_linked_list(linked_list_t *list, size_t i);
/* This function retrieves a pointer to the ith node. */
[[gnu::nonnull(1)]] [[nodiscard]]
node_t* get_node_i_single_linked_list(linked_list_t *list, size_t i);
/* This function attempts to find the index of a given node, by pointer. */
[[gnu::nonnull(1,2)]] [[nodiscard]]
size_t get_node_index_pointer_single_linked_list(linked_list_t *list, node_t *node);
/* This function attempts to find the index of a given node, by data. */
[[gnu::nonnull(1,2)]] [[nodiscard]]
size_t get_node_index_data_single_linked_list(linked_list_t *list, void *data, int (*comparison_function)(const void*, const void*));
/* This function deletes the ith node. */
[[gnu::nonnull(1)]]
void remove_node_i_single_linked_list(linked_list_t *list, size_t i);
/* This function deletes the ith node and the data stored within. */
[[gnu::nonnull(1)]]
void remove_node_i_data_single_linked_list(linked_list_t *list, size_t i, void (*free_function)(const void*));
/* This function reads the data at the first node. */
[[gnu::nonnull(1)]] [[nodiscard]]
void* read_node_head_single_linked_list(linked_list_t *list);
/* This function retrieves the first node. */
[[gnu::nonnull(1)]] [[nodiscard]]
node_t* get_node_head_single_linked_list(linked_list_t *list);
/* This function deletes the first node. */
[[gnu::nonnull(1)]]
void remove_node_head_single_linked_list(linked_list_t *list);
/* This function deletes the first node and the data thereof. */
[[gnu::nonnull(1)]]
void remove_node_head_data_single_linked_list(linked_list_t *list, void (*free_function)(const void*));
/* This function reads the data at the last node. */
[[gnu::nonnull(1)]] [[nodiscard]]
void* read_node_tail_single_linked_list(linked_list_t *list);
/* This function retrieves the last node. */
[[gnu::nonnull(1)]] [[nodiscard]]
node_t* get_node_tail_single_linked_list(linked_list_t *list);
/* This function deletes the last node. */
[[gnu::nonnull(1)]]
void remove_node_tail_single_linked_list(linked_list_t *list);
/* This function deletes the last node and the data thereof. */
[[gnu::nonnull(1)]]
void remove_node_tail_data_single_linked_list(linked_list_t *list, void (*free_function)(const void*));
/* This function deletes all the nodes of the given list and the list itself. */
[[gnu::nonnull(1)]] [[nodiscard]]
int clear_list_single_linked_list(linked_list_t **list);
/* This function deletes all the nodes and data stored within of the given list and the list itself. */
[[gnu::nonnull(1)]] [[nodiscard]]
int clear_list_data_single_linked_list(linked_list_t **list, void (*free_function)(const void*));
/* This function deletes all the nodes of a linked list. */
[[gnu::nonnull(1)]]
void clear_list_nodes_single_linked_list(linked_list_t *list);
/* This function deletes all the nodes of a linked list and the data thereof. */
[[gnu::nonnull(1)]]
void clear_list_nodes_data_single_linked_list(linked_list_t *list, void (*free_function)(const void*));
/* This function attempts to serialize a linked list into an array, it relies on an array setting function and an allocated buffer. */
[[gnu::nonnull(1,3)]] [[nodiscard]]
void *serialize_linked_list(linked_list_t *list, void (*array_setting_function)(void*, size_t, void*), void *array);
#endif /* SINGLE_LINKED_LIST_H */