data_structures
|
Go to the source code of this file.
Data Structures | |
struct | s_link |
A link in a doubly-linked list. More... | |
struct | s_list |
Doubly-linked list of generic items. More... | |
Typedefs | |
typedef struct s_link | t_link |
typedef struct s_list | t_list |
Functions | |
void | list_add_first (t_list *alst, const void *data) |
Adds a copy of the specified element at the front of this list. More... | |
void | list_add_last (t_list *alst, const void *data) |
Adds a copy of the specified element at the back of this list. More... | |
void | list_delete (t_list *alst) |
Deletes the list and frees all memory taken by its contents. More... | |
void * | list_unlink_first (t_list *alst) |
Removes the first item in the list and returns it. More... | |
void * | list_unlink_last (t_list *alst) |
Removes the last item in the list and returns it. More... | |
void * | list_unlink (t_list *alst, size_t index) |
Removes the item at the specified position in the list and returns it. More... | |
void | list_remove_first (t_list *alst) |
Removes the first item in the list. More... | |
void | list_remove_last (t_list *alst) |
Removes the last item in the list. More... | |
void | list_remove (t_list *alst, size_t index) |
Removes the item at the specified position in the list. More... | |
void * | list_peek_first (const t_list *alst) |
Returns the first item in the list. More... | |
void * | list_peek_last (const t_list *alst) |
Returns the last item in the list. More... | |
void * | list_peek (const t_list *alst, size_t index) |
Returns the item at the specified position in the list. More... | |
size_t | list_size (const t_list *alst) |
Returns the number of items in this list. More... | |
t_list * | list_new (const t_type *type) |
Allocates memory and initializes an empty list. More... | |
void | list_merge_sort (t_list *alst) |
Sorts this list in ascending order using in-place merge sort. More... | |
t_list * | list_copy (const t_list *alst) |
Copies an list and all it contents. More... | |
void list_add_first | ( | t_list * | alst, |
const void * | data | ||
) |
Adds a copy of the specified element at the front of this list.
data | The item to be copied |
Definition at line 16 of file list_add_first.c.
void list_add_last | ( | t_list * | alst, |
const void * | data | ||
) |
Adds a copy of the specified element at the back of this list.
data | The item to be copied |
Definition at line 16 of file list_add_last.c.
Copies an list and all it contents.
Definition at line 16 of file list_copy.c.
void list_delete | ( | t_list * | alst | ) |
Deletes the list and frees all memory taken by its contents.
Definition at line 16 of file list_delete.c.
void list_merge_sort | ( | t_list * | alst | ) |
Sorts this list in ascending order using in-place merge sort.
cmp
function). Definition at line 75 of file list_merge_sort.c.
Allocates memory and initializes an empty list.
the | type of items that this list will hold |
Definition at line 16 of file list_new.c.
void* list_peek | ( | const t_list * | alst, |
size_t | index | ||
) |
Returns the item at the specified position in the list.
The item is kept in the list.
NULL
if the list is empty. O(N/2)
in the number of items in the worst case. Definition at line 16 of file list_peek.c.
void* list_peek_first | ( | const t_list * | alst | ) |
Returns the first item in the list.
The item is kept in the list.
NULL
if the list is empty. Definition at line 16 of file list_peek_first.c.
void* list_peek_last | ( | const t_list * | alst | ) |
Returns the last item in the list.
The item is kept in the list.
NULL
if the list is empty. Definition at line 16 of file list_peek_last.c.
void list_remove | ( | t_list * | alst, |
size_t | index | ||
) |
Removes the item at the specified position in the list.
O(N/2)
in the number of items in the worst case. Definition at line 16 of file list_remove.c.
void list_remove_first | ( | t_list * | alst | ) |
Removes the first item in the list.
Definition at line 16 of file list_remove_first.c.
void list_remove_last | ( | t_list * | alst | ) |
Removes the last item in the list.
Definition at line 16 of file list_remove_last.c.
size_t list_size | ( | const t_list * | alst | ) |
Returns the number of items in this list.
Definition at line 16 of file list_size.c.
void* list_unlink | ( | t_list * | alst, |
size_t | index | ||
) |
Removes the item at the specified position in the list and returns it.
NULL
if the list is empty. O(N/2)
in the number of items in the worst case. Definition at line 41 of file list_unlink.c.
void* list_unlink_first | ( | t_list * | alst | ) |
Removes the first item in the list and returns it.
NULL
if the list is empty. Definition at line 16 of file list_unlink_first.c.
void* list_unlink_last | ( | t_list * | alst | ) |
Removes the last item in the list and returns it.
NULL
if the list is empty. Definition at line 16 of file list_unlink_last.c.