ccontainer/cc_linkedlist.h file

Contents

Classes

struct cc_linkedlist_node
struct cc_linkedlist

Typedefs

using cc_linkedlist_node_t = struct cc_linkedlist_node
using cc_linkedlist_t = struct cc_linkedlist

Functions

auto compare(void* a, void* b, size_t size) -> int
auto cc_linkedlist_node_create(void* data, size_t data_size) -> cc_linkedlist_node_t*
create single node for linked list
void cc_linkedlist_init(cc_linkedlist_t* list, size_t data_size)
initialize an empty list
auto cc_linkedlist_size(cc_linkedlist_node_t* head) -> size_t
gets the current size of linked list
void cc_linkedlist_insert_front(cc_linkedlist_t* list, void* data)
insert data beggining of the list
void cc_linkedlist_insert_back(cc_linkedlist_t* list, void* data)
insert data end of the list
void cc_linkedlist_node_delete(cc_linkedlist_t* list, void* data)
delete the first node with given data
auto cc_linkedlist_node_search(cc_linkedlist_t* list, void* data) -> cc_linkedlist_node_t*
search node with given data
void cc_linkedlist_free(cc_linkedlist_t* list)
delete the entire list from heap

Defines

#define CC_LINKEDLIST_LOG(format, ...)

Function documentation

cc_linkedlist_node_t* cc_linkedlist_node_create(void* data, size_t data_size)

create single node for linked list

Parameters
data to push to the linked list
data_size size of the data for allocating memory for it
Returns cc_linkedlist_node_t*

void cc_linkedlist_init(cc_linkedlist_t* list, size_t data_size)

initialize an empty list

Parameters
list list that head node points to NULL
data_size given by user

size_t cc_linkedlist_size(cc_linkedlist_node_t* head)

gets the current size of linked list

Parameters
head to point specified linked list
Returns size_t number of nodes

void cc_linkedlist_insert_front(cc_linkedlist_t* list, void* data)

insert data beggining of the list

Parameters
list list that data will be instered
data data that will be insert

void cc_linkedlist_insert_back(cc_linkedlist_t* list, void* data)

insert data end of the list

Parameters
list list that data will be instered
data data that will be insert

void cc_linkedlist_node_delete(cc_linkedlist_t* list, void* data)

delete the first node with given data

Parameters
list
data

cc_linkedlist_node_t* cc_linkedlist_node_search(cc_linkedlist_t* list, void* data)

search node with given data

Parameters
list
data
Returns cc_linkedlist_node_t* node that contains requested data

void cc_linkedlist_free(cc_linkedlist_t* list)

delete the entire list from heap

Parameters
list to delete