109#include "qinternal.h"
110#include "containers/qqueue.h"
130 qqueue_t *queue = (qqueue_t *) malloc(
sizeof(qqueue_t));
136 memset((
void *) queue, 0,
sizeof(qqueue_t));
137 queue->list =
qlist(options);
138 if (queue->list == NULL) {
178 return queue->list->setsize(queue->list, max);
196 return queue->list->addlast(queue->list, data, size);
218 return queue->list->addlast(queue->list, str, strlen(str) + 1);
234 return queue->list->addlast(queue->list, &num,
sizeof(num));
250 return queue->list->popfirst(queue->list, size);
269 char *str = queue->list->popfirst(queue->list, &strsize);
271 str[strsize - 1] =
'\0';
293 int64_t *pnum = queue->list->popfirst(queue->list, NULL);
321 return queue->list->popat(queue->list, index, size);
337void *
qqueue_get(qqueue_t *queue,
size_t *size,
bool newmem) {
338 return queue->list->getfirst(queue->list, size, newmem);
357 char *str = queue->list->getfirst(queue->list, &strsize,
true);
359 str[strsize - 1] =
'\0';
381 int64_t *pnum = queue->list->getfirst(queue->list, NULL,
true);
409void *
qqueue_getat(qqueue_t *queue,
int index,
size_t *size,
bool newmem) {
410 return queue->list->getat(queue->list, index, size, newmem);
421 return queue->list->size(queue->list);
430 queue->list->clear(queue->list);
442 return queue->list->debug(queue->list, out);
453 queue->list->free(queue->list);
qlist_t * qlist(int options)
Create new qlist_t linked-list container.
int64_t qqueue_getint(qqueue_t *queue)
qqueue->getint(): Returns an integer at the top of this queue without removing it.
void * qqueue_get(qqueue_t *queue, size_t *size, bool newmem)
qqueue->get(): Returns an element at the top of this queue without removing it.
bool qqueue_push(qqueue_t *queue, const void *data, size_t size)
qqueue->push(): Pushes an element onto the top of this queue.
bool qqueue_pushstr(qqueue_t *queue, const char *str)
qqueue->pushstr(): Pushes a string onto the top of this queue.
bool qqueue_debug(qqueue_t *queue, FILE *out)
qqueue->debug(): Print out stored elements for debugging purpose.
void qqueue_clear(qqueue_t *queue)
qqueue->clear(): Removes all of the elements from this queue.
void * qqueue_pop(qqueue_t *queue, size_t *size)
qqueue->pop(): Removes a element at the top of this queue and returns that element.
char * qqueue_popstr(qqueue_t *queue)
qqueue->popstr(): Removes a element at the top of this queue and returns that element.
size_t qqueue_size(qqueue_t *queue)
qqueue->size(): Returns the number of elements in this queue.
void qqueue_free(qqueue_t *queue)
qqueue->free(): Free qqueue_t
char * qqueue_getstr(qqueue_t *queue)
qqueue->getstr(): Returns an string at the top of this queue without removing it.
void * qqueue_popat(qqueue_t *queue, int index, size_t *size)
qqueue->popat(): Returns and remove the element at the specified position in this queue.
qqueue_t * qqueue(int options)
Create new queue container.
bool qqueue_pushint(qqueue_t *queue, int64_t num)
qqueue->pushint(): Pushes a integer onto the top of this queue.
size_t qqueue_setsize(qqueue_t *queue, size_t max)
qqueue->setsize(): Sets maximum number of elements allowed in this queue.
int64_t qqueue_popint(qqueue_t *queue)
qqueue->popint(): Removes a integer at the top of this queue and returns that element.
void * qqueue_getat(qqueue_t *queue, int index, size_t *size, bool newmem)
qqueue->getat(): Returns an element at the specified position in this queue without removing it.