qLibc
|
Doubly Linked-list implementation. More...
Go to the source code of this file.
Functions | |
qlist_t * | qlist (int options) |
Create new qlist_t linked-list container. | |
size_t | qlist_setsize (qlist_t *list, size_t max) |
qlist->setsize(): Limit maximum number of elements allowed in this list. | |
bool | qlist_addfirst (qlist_t *list, const void *data, size_t size) |
qlist->addfirst(): Inserts a element at the beginning of this list. | |
bool | qlist_addlast (qlist_t *list, const void *data, size_t size) |
qlist->addlast(): Appends a element to the end of this list. | |
bool | qlist_addat (qlist_t *list, int index, const void *data, size_t size) |
qlist->addat(): Inserts a element at the specified position in this list. | |
void * | qlist_getfirst (qlist_t *list, size_t *size, bool newmem) |
qlist->getfirst(): Returns the first element in this list. | |
void * | qlist_getlast (qlist_t *list, size_t *size, bool newmem) |
qlist->getlast(): Returns the last element in this list. | |
void * | qlist_getat (qlist_t *list, int index, size_t *size, bool newmem) |
qlist->getat(): Returns the element at the specified position in this list. | |
void * | qlist_popfirst (qlist_t *list, size_t *size) |
qlist->popfirst(): Returns and remove the first element in this list. | |
void * | qlist_poplast (qlist_t *list, size_t *size) |
qlist->getlast(): Returns and remove the last element in this list. | |
void * | qlist_popat (qlist_t *list, int index, size_t *size) |
qlist->popat(): Returns and remove the element at the specified position in this list. | |
bool | qlist_removefirst (qlist_t *list) |
qlist->removefirst(): Removes the first element in this list. | |
bool | qlist_removelast (qlist_t *list) |
qlist->removelast(): Removes the last element in this list. | |
bool | qlist_removeat (qlist_t *list, int index) |
qlist->removeat(): Removes the element at the specified position in this list. | |
bool | qlist_getnext (qlist_t *list, qlist_obj_t *obj, bool newmem) |
qlist->getnext(): Get next element in this list. | |
size_t | qlist_size (qlist_t *list) |
qlist->size(): Returns the number of elements in this list. | |
size_t | qlist_datasize (qlist_t *list) |
qlist->size(): Returns the sum of total element size. | |
void | qlist_reverse (qlist_t *list) |
qlist->reverse(): Reverse the order of elements. | |
void | qlist_clear (qlist_t *list) |
qlist->clear(): Removes all of the elements from this list. | |
void * | qlist_toarray (qlist_t *list, size_t *size) |
qlist->toarray(): Returns the serialized chunk containing all the elements in this list. | |
char * | qlist_tostring (qlist_t *list) |
qlist->tostring(): Returns a string representation of this list, containing string representation of each element. | |
bool | qlist_debug (qlist_t *list, FILE *out) |
qlist->debug(): Prints out stored elements for debugging purpose. | |
void | qlist_lock (qlist_t *list) |
qlist->lock(): Enters critical section. | |
void | qlist_unlock (qlist_t *list) |
qlist->unlock(): Leaves critical section. | |
void | qlist_free (qlist_t *list) |
qlist->free(): Free qlist_t. | |
Doubly Linked-list implementation.
qlist container is a doubly Linked-List implementation. qlist provides uniformly named methods to add, get, pop and remove an element at the beginning and end of the list. These operations allow qlist to be used as a stack, queue, or double-ended queue.
Definition in file qlist.c.
qlist_t * qlist | ( | int | options | ) |
Create new qlist_t linked-list container.
options | combination of initialization options. |
errno | will be set in error condition. -ENOMEM : Memory allocation failure. |
size_t qlist_setsize | ( | qlist_t * | list, |
size_t | max | ||
) |
bool qlist_addfirst | ( | qlist_t * | list, |
const void * | data, | ||
size_t | size | ||
) |
qlist->addfirst(): Inserts a element at the beginning of this list.
list | qlist_t container pointer. |
data | a pointer which points data memory. |
size | size of the data. |
errno | will be set in error condition.
|
bool qlist_addlast | ( | qlist_t * | list, |
const void * | data, | ||
size_t | size | ||
) |
qlist->addlast(): Appends a element to the end of this list.
list | qlist_t container pointer. |
data | a pointer which points data memory. |
size | size of the data. |
errno | will be set in error condition.
|
bool qlist_addat | ( | qlist_t * | list, |
int | index, | ||
const void * | data, | ||
size_t | size | ||
) |
qlist->addat(): Inserts a element at the specified position in this list.
list | qlist_t container pointer. |
index | index at which the specified element is to be inserted. |
data | a pointer which points data memory. |
size | size of the data. |
errno | will be set in error condition.
|
void * qlist_getfirst | ( | qlist_t * | list, |
size_t * | size, | ||
bool | newmem | ||
) |
qlist->getfirst(): Returns the first element in this list.
list | qlist_t container pointer. |
size | if size is not NULL, element size will be stored. |
newmem | whether or not to allocate memory for the element. |
errno | will be set in error condition.
|
void * qlist_getlast | ( | qlist_t * | list, |
size_t * | size, | ||
bool | newmem | ||
) |
qlist->getlast(): Returns the last element in this list.
list | qlist_t container pointer. |
size | if size is not NULL, element size will be stored. |
newmem | whether or not to allocate memory for the element. |
errno | will be set in error condition. ENOENT : List is empty. ENOMEM : Memory allocation failure. |
void * qlist_getat | ( | qlist_t * | list, |
int | index, | ||
size_t * | size, | ||
bool | newmem | ||
) |
qlist->getat(): Returns the element at the specified position in this list.
list | qlist_t container pointer. |
index | index at which the specified element is to be inserted |
size | if size is not NULL, element size will be stored. |
newmem | whether or not to allocate memory for the element. |
errno | |
errno | will be set in error condition. -ERANGE : Index out of range. -ENOMEM : Memory allocation failure. |
void * qlist_popfirst | ( | qlist_t * | list, |
size_t * | size | ||
) |
qlist->popfirst(): Returns and remove the first element in this list.
list | qlist_t container pointer. |
size | if size is not NULL, element size will be stored. |
errno | will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure. |
void * qlist_poplast | ( | qlist_t * | list, |
size_t * | size | ||
) |
qlist->getlast(): Returns and remove the last element in this list.
list | qlist_t container pointer. |
size | if size is not NULL, element size will be stored. |
errno | will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure. |
void * qlist_popat | ( | qlist_t * | list, |
int | index, | ||
size_t * | size | ||
) |
qlist->popat(): Returns and remove the element at the specified position in this list.
list | qlist_t container pointer. |
index | index at which the specified element is to be inserted |
size | if size is not NULL, element size will be stored. |
errno | will be set in error condition. -ERANGE : Index out of range. -ENOMEM : Memory allocation failure. |
bool qlist_removefirst | ( | qlist_t * | list | ) |
bool qlist_removelast | ( | qlist_t * | list | ) |
bool qlist_removeat | ( | qlist_t * | list, |
int | index | ||
) |
qlist->removeat(): Removes the element at the specified position in this list.
list | qlist_t container pointer. |
index | index at which the specified element is to be removed. |
errno | will be set in error condition. -ERANGE : Index out of range. |
bool qlist_getnext | ( | qlist_t * | list, |
qlist_obj_t * | obj, | ||
bool | newmem | ||
) |
qlist->getnext(): Get next element in this list.
list | qlist_t container pointer. |
obj | found data will be stored in this structure |
newmem | whether or not to allocate memory for the element. |
errno | will be set in error condition. -ENOENT : No next element. -ENOMEM : Memory allocation failure. |
size_t qlist_size | ( | qlist_t * | list | ) |
size_t qlist_datasize | ( | qlist_t * | list | ) |
void qlist_reverse | ( | qlist_t * | list | ) |
void qlist_clear | ( | qlist_t * | list | ) |
void * qlist_toarray | ( | qlist_t * | list, |
size_t * | size | ||
) |
qlist->toarray(): Returns the serialized chunk containing all the elements in this list.
list | qlist_t container pointer. |
size | if size is not NULL, chunk size will be stored. |
errno | will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure. |
char * qlist_tostring | ( | qlist_t * | list | ) |
qlist->tostring(): Returns a string representation of this list, containing string representation of each element.
list | qlist_t container pointer. |
errno | will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure. |
bool qlist_debug | ( | qlist_t * | list, |
FILE * | out | ||
) |
qlist->debug(): Prints out stored elements for debugging purpose.
list | qlist_t container pointer. |
out | output stream FILE descriptor such like stdout, stderr. |
errno | will be set in error condition. -EIO : Invalid output stream. |
void qlist_lock | ( | qlist_t * | list | ) |
void qlist_unlock | ( | qlist_t * | list | ) |