|
| 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 an element at the beginning of this list.
|
| bool | qlist_addlast (qlist_t *list, const void *data, size_t size) |
| | qlist->addlast(): Appends an element to the end of this list.
|
| bool | qlist_addat (qlist_t *list, int index, const void *data, size_t size) |
| | qlist->addat(): Inserts an 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 removes the first element in this list.
|
| void * | qlist_poplast (qlist_t *list, size_t *size) |
| | qlist->poplast(): Returns and removes the last element in this list.
|
| void * | qlist_popat (qlist_t *list, int index, size_t *size) |
| | qlist->popat(): Returns and removes 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 stored elements for debugging purposes.
|
| 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.
[Conceptional Data Structure Diagram]
last~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
|
+-----------+ doubly +-----------+ doubly +-|---------+
first~~~|~> 0 <~|~~~~~~~~~~|~> 1 <~|~~~~~~~~~~|~> N |
+-----|-----+ linked +-----|-----+ linked +-----|-----+
| | |
+-----v---------------+ | +-----v-----+
| DATA A | | | DATA N |
+---------------------+ | +-----------+
+---------------------v------------------+
| DATA B |
+----------------------------------------+
qlist_t *list =
qlist(QLIST_THREADSAFE);
list->addlast(list, "e1", sizeof("e1"));
list->addlast(list, "e2", sizeof("e2"));
list->addlast(list, "e3", sizeof("e3"));
char *e1 = (char*)list->getfirst(list, NULL, true));
char *e3 = (char*)list->getat(list, -1, NULL, false));
(...omit...)
free(e1);
char *e2 = (char*)list->popat(list, 1, NULL));
(...omit...)
free(e2);
list->debug(list, stdout, true);
qlist_obj_t obj;
memset((void*)&obj, 0, sizeof(obj));
list->lock(list);
while (list->getnext(list, &obj, false) == true) {
printf("DATA=%s, SIZE=%zu\n", (char*)obj.data, obj.size);
}
list->unlock(list);
list->free(list);
qlist_t * qlist(int options)
Create new qlist_t linked-list container.
Definition in file qlist.c.