MentOS
0.8.0
The Mentoring Operating System
|
Functions | |
static listnode_t * | __node_alloc (void) |
Allocates the memory for a node. More... | |
static void | __node_dealloc (listnode_t *node) |
Frees the memory of a node. More... | |
static list_t * | __list_alloc (void) |
Allocates the memory for a list. More... | |
static void | __list_dealloc (list_t *list) |
Frees the memory of a list. More... | |
list_t * | list_create (void) |
Create a list and set head, tail to NULL, and size to 0. More... | |
unsigned int | list_size (list_t *list) |
Get list size. More... | |
int | list_empty (list_t *list) |
Checks if the list is empty. More... | |
listnode_t * | list_insert_front (list_t *list, void *value) |
Insert a value at the front of list. More... | |
listnode_t * | list_insert_back (list_t *list, void *value) |
Insert a value at the back of list. More... | |
void * | list_remove_node (list_t *list, listnode_t *node) |
Given a listnode, remove it from list. More... | |
void * | list_remove_front (list_t *list) |
Remove a value at the front of list. More... | |
void * | list_remove_back (list_t *list) |
Remove a value at the back of list. More... | |
listnode_t * | list_find (list_t *list, void *value) |
Searches the node of the list which points at the given value. More... | |
void | list_push_back (list_t *list, void *value) |
Insert after tail of list(same as insert back). More... | |
listnode_t * | list_pop_back (list_t *list) |
Remove and return the tail of the list. More... | |
listnode_t * | list_pop_front (list_t *list) |
Remove and return the head of the list. More... | |
void | list_push_front (list_t *list, void *value) |
Insert before head of list(same as insert front). More... | |
void * | list_peek_front (list_t *list) |
Get the value of the first element but not remove it. More... | |
void * | list_peek_back (list_t *list) |
Get the value of the last element but not remove it. More... | |
int | list_get_index_of_value (list_t *list, void *value) |
Checks if the given value is contained inside the list. More... | |
listnode_t * | list_get_node_by_index (list_t *list, unsigned int index) |
Returns the node at the given index. More... | |
void * | list_remove_by_index (list_t *list, unsigned int index) |
Removes a node from the list at the given index. More... | |
void | list_destroy (list_t *list) |
Destroy a list. More... | |
void | list_merge (list_t *target, list_t *source) |
Append source at the end of target. More... | |
|
inlinestatic |
Allocates the memory for a list.
|
inlinestatic |
Frees the memory of a list.
list | the list we want to free. |
|
inlinestatic |
Allocates the memory for a node.
|
inlinestatic |
Frees the memory of a node.
node | the new we want to free. |
list_t* list_create | ( | void | ) |
Create a list and set head, tail to NULL, and size to 0.
void list_destroy | ( | list_t * | list | ) |
Destroy a list.
list | The list. |
int list_empty | ( | list_t * | list | ) |
Checks if the list is empty.
list | The list. |
listnode_t* list_find | ( | list_t * | list, |
void * | value | ||
) |
Searches the node of the list which points at the given value.
list | The list. |
value | The value that has to be searched. |
int list_get_index_of_value | ( | list_t * | list, |
void * | value | ||
) |
Checks if the given value is contained inside the list.
list | The list. |
value | The value to search. |
listnode_t* list_get_node_by_index | ( | list_t * | list, |
unsigned int | index | ||
) |
Returns the node at the given index.
list | The list. |
index | The index of the desired node. |
listnode_t* list_insert_back | ( | list_t * | list, |
void * | value | ||
) |
Insert a value at the back of list.
list | The list. |
value | The value to insert. |
listnode_t* list_insert_front | ( | list_t * | list, |
void * | value | ||
) |
Insert a value at the front of list.
list | The list. |
value | The value to insert. |
Append source at the end of target.
target | Where the element are added. |
source | Where the element are removed. |
Beware, source is destroyed.
void* list_peek_back | ( | list_t * | list | ) |
Get the value of the last element but not remove it.
list | The list. |
void* list_peek_front | ( | list_t * | list | ) |
Get the value of the first element but not remove it.
list | The list. |
listnode_t* list_pop_back | ( | list_t * | list | ) |
Remove and return the tail of the list.
list | The list. |
User is responsible for freeing the returned node and the value.
listnode_t* list_pop_front | ( | list_t * | list | ) |
Remove and return the head of the list.
list | The list. |
User is responsible for freeing the returned node and the value.
void list_push_back | ( | list_t * | list, |
void * | value | ||
) |
Insert after tail of list(same as insert back).
list | The list. |
value | The value to insert. |
void list_push_front | ( | list_t * | list, |
void * | value | ||
) |
Insert before head of list(same as insert front).
list | The list. |
value | The value to insert. |
void* list_remove_back | ( | list_t * | list | ) |
Remove a value at the back of list.
list | The list. |
void* list_remove_by_index | ( | list_t * | list, |
unsigned int | index | ||
) |
Removes a node from the list at the given index.
list | The list. |
index | The index of the node we need to remove. |
void* list_remove_front | ( | list_t * | list | ) |
Remove a value at the front of list.
list | The list. |
void* list_remove_node | ( | list_t * | list, |
listnode_t * | node | ||
) |
Given a listnode, remove it from list.
list | The list. |
node | The node that has to be removed. |
unsigned int list_size | ( | list_t * | list | ) |
Get list size.
list | The list. |