Turnstone Operating System
|
generic linked list implementation More...
#include <types.h>
#include <list.h>
#include <indexer.h>
#include <cpu/sync.h>
#include <strings.h>
#include <logging.h>
Classes | |
struct | list_item_t |
struct | list_t |
list internal interface More... | |
Typedefs | |
typedef struct list_item_t | list_item_t |
short hand for struct | |
typedef struct list_t | list_t |
short hand for struct | |
Functions | |
MODULE ("turnstone.lib.list") | |
int8_t | list_default_data_comparator (const void *data1, const void *data2) |
linked list default data comparator | |
int8_t | list_string_comprator (const void *data1, const void *data2) |
memory_heap_t * | list_get_heap (list_t *list) |
returns list's heap | |
list_data_comparator_f | list_set_comparator (list_t *list, list_data_comparator_f comparator) |
updates list's comparator and returns the old one. | |
int8_t | list_set_equality_comparator (list_t *list, list_data_comparator_f comparator) |
sets equality comparator for list | |
size_t | list_size (const list_t *list) |
returns item count at linked list | |
int8_t | list_merge (list_t *self, list_t *list) |
merge given list into self list | |
const void * | list_get_data_from_listitem (list_item_t *item) |
return data inside implicit list item type | |
list_t * | linkedlist_create_with_type (memory_heap_t *heap, list_type_t type, list_data_comparator_f comparator, indexer_t *indexer) |
list_t * | arraylist_create_with_type (memory_heap_t *heap, list_type_t type, list_data_comparator_f comparator, indexer_t *indexer) |
list_t * | list_create_with_type (memory_heap_t *heap, list_type_t type, list_data_comparator_f comparator, indexer_t *indexer) |
linked list creator | |
uint8_t | linkedlist_destroy_with_type (list_t *list, list_destroy_type_t type, list_item_destroyer_callback_f destroyer) |
uint8_t | arraylist_destroy_with_type (list_t *list, list_destroy_type_t type, list_item_destroyer_callback_f destroyer) |
uint8_t | list_destroy_with_type (list_t *list, list_destroy_type_t type, list_item_destroyer_callback_f destroyer) |
destroys linked list | |
size_t | linkedlist_insert_at (list_t *list, const void *data, list_insert_delete_at_t where, size_t position) |
size_t | arraylist_insert_at (list_t *list, const void *data, list_insert_delete_at_t where, size_t position) |
size_t | list_insert_at (list_t *list, const void *data, list_insert_delete_at_t where, size_t position) |
general method for inserting or deleting data from list types. | |
const void * | linkedlist_delete_at (list_t *list, const void *data, list_insert_delete_at_t where, size_t position) |
const void * | arraylist_delete_at (list_t *list, const void *data, list_insert_delete_at_t where, size_t position) |
const void * | list_delete_at (list_t *list, const void *data, list_insert_delete_at_t where, size_t position) |
general method for inserting or deleting data from list types. | |
const void * | linkedlist_get_data_at_position (list_t *list, size_t position) |
const void * | arraylist_get_data_at_position (list_t *list, size_t position) |
const void * | list_get_data_at_position (list_t *list, size_t position) |
returns position of given data. | |
int8_t | linkedlist_get_position (list_t *list, const void *data, size_t *position) |
int8_t | arraylist_get_position (list_t *list, const void *data, size_t *position) |
int8_t | list_get_position (list_t *list, const void *data, size_t *position) |
returns position of given data. | |
iterator_t * | linkedlist_iterator_create (list_t *list) |
iterator_t * | arraylist_iterator_create (list_t *list) |
iterator_t * | list_iterator_create (list_t *list) |
creates an iterator from the list | |
int8_t | arraylist_set_capacity (list_t *list, size_t capacity) |
int8_t | list_set_capacity (list_t *list, size_t capacity) |
sets list's capacity | |
list_t * | linkedlist_duplicate_list_with_heap (memory_heap_t *heap, list_t *list) |
list_t * | arraylist_duplicate_list_with_heap (memory_heap_t *heap, list_t *list) |
list_t * | list_duplicate_list_with_heap (memory_heap_t *heap, list_t *list) |
duplicates list at the given heap | |
generic linked list implementation
This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.
typedef struct list_item_t list_item_t |
short hand for struct
linked list item implicit type
typedef struct list_t list_t |
short hand for struct
linked list implicit type
list_t * list_create_with_type | ( | memory_heap_t * | heap, |
list_type_t | type, | ||
list_data_comparator_f | comparator, | ||
indexer_t * | indexer ) |
linked list creator
[in] | heap | memory_heap_t the heap where linked list will be at. |
[in] | type | list_type_t linked list type |
[in] | comparator | list_data_comparator_f data comparator used at sorted list |
[in] | indexer | indexer_t index linked list nodes. |
creates linked list with given arguments. for each type of linked list there is a macro. do not use this method directly.
if heap is null then linked list created at default heap.
int8_t list_default_data_comparator | ( | const void * | data1, |
const void * | data2 ) |
linked list default data comparator
data1 | item 1 |
data2 | item 2 |
assumes data1 and data2 is size_t pointer
const void * list_delete_at | ( | list_t * | list, |
const void * | data, | ||
list_insert_delete_at_t | where, | ||
size_t | position ) |
general method for inserting or deleting data from list types.
[in] | list | the list |
[in] | data | the data |
[in] | where | where and how the data will be inserted |
[in] | position | if data will be deleted by position |
uint8_t list_destroy_with_type | ( | list_t * | list, |
list_destroy_type_t | type, | ||
list_item_destroyer_callback_f | destroyer ) |
destroys linked list
[in] | list | list_t* the list to be destoyed |
[in] | type | list_destroy_type_t the type with |
[in] | destroyer | list_item_destroyer_callback_f destroyer callback, it frees list item |
this method destroys only the linked list with choice of preserving data. if you do not destroy the data a memory leak will be happened if without data destroying
list_t * list_duplicate_list_with_heap | ( | memory_heap_t * | heap, |
list_t * | list ) |
duplicates list at the given heap
[in] | heap | the heap where the list will be created |
[in] | list | source list |
if heap is NULL then the new heap is same as source list's heap.
returns position of given data.
list | list to search |
position | position of data |
const void * list_get_data_from_listitem | ( | list_item_t * | list_item | ) |
return data inside implicit list item type
[in] | list_item | list item |
memory_heap_t * list_get_heap | ( | list_t * | list | ) |
returns position of given data.
[in] | list | list to search |
[in] | data | data to search |
[position] | position the position of data if found |
size_t list_insert_at | ( | list_t * | list, |
const void * | data, | ||
list_insert_delete_at_t | where, | ||
size_t | position ) |
general method for inserting or deleting data from list types.
[in] | list | the list |
[in] | data | the data |
[in] | where | where and how the data will be inserted |
[in] | position | if data will be added by position |
iterator_t * list_iterator_create | ( | list_t * | list | ) |
creates an iterator from the list
[in] | list | source list |
the returned type is implicit. see also list_iterator_internal_t iterator is created at the heap of list.
merge given list into self list
[in] | self | source list |
[in] | list | destination list |
sets list's capacity
[in] | list | list to be modified |
capacity | new capacity |
if list is null then this method returns -1. if new capacity is less than current size of list then this method returns -1. if list is not array list then this method returns -2.
list_data_comparator_f list_set_comparator | ( | list_t * | list, |
list_data_comparator_f | comparator ) |
updates list's comparator and returns the old one.
[in] | list | list to be modified |
comparator | new comparator |
sets equality comparator for list
[in] | list | source list |
[in] | comparator | comparator function |