qLibc
|
Stack implementation. More...
Go to the source code of this file.
Functions | |
qstack_t * | qstack (int options) |
Create a new stack container. | |
size_t | qstack_setsize (qstack_t *stack, size_t max) |
qstack->setsize(): Sets maximum number of elements allowed in this stack. | |
bool | qstack_push (qstack_t *stack, const void *data, size_t size) |
qstack->push(): Pushes an element onto the top of this stack. | |
bool | qstack_pushstr (qstack_t *stack, const char *str) |
qstack->pushstr(): Pushes a string onto the top of this stack. | |
bool | qstack_pushint (qstack_t *stack, int64_t num) |
qstack->pushint(): Pushes a integer onto the top of this stack. | |
void * | qstack_pop (qstack_t *stack, size_t *size) |
qstack->pop(): Removes a element at the top of this stack and returns that element. | |
char * | qstack_popstr (qstack_t *stack) |
qstack->popstr(): Removes a element at the top of this stack and returns that element. | |
int64_t | qstack_popint (qstack_t *stack) |
qstack->popint(): Removes a integer at the top of this stack and returns that element. | |
void * | qstack_popat (qstack_t *stack, int index, size_t *size) |
qstack->popat(): Returns and remove the element at the specified position in this stack. | |
void * | qstack_get (qstack_t *stack, size_t *size, bool newmem) |
qstack->get(): Returns an element at the top of this stack without removing it. | |
char * | qstack_getstr (qstack_t *stack) |
qstack->getstr(): Returns an string at the top of this stack without removing it. | |
int64_t | qstack_getint (qstack_t *stack) |
qstack->getint(): Returns an integer at the top of this stack without removing it. | |
void * | qstack_getat (qstack_t *stack, int index, size_t *size, bool newmem) |
qstack->getat(): Returns an element at the specified position in this stack without removing it. | |
size_t | qstack_size (qstack_t *stack) |
qstack->size(): Returns the number of elements in this stack. | |
void | qstack_clear (qstack_t *stack) |
qstack->clear(): Removes all of the elements from this stack. | |
bool | qstack_debug (qstack_t *stack, FILE *out) |
qstack->debug(): Print out stored elements for debugging purpose. | |
void | qstack_free (qstack_t *stack) |
qstack->free(): Free qstack_t | |
Stack implementation.
qstack container is a stack implementation. It represents a last-in-first-out(LIFO). It extends qlist container that allow a linked-list to be treated as a stack.
Definition in file qstack.c.
qstack_t * qstack | ( | int | options | ) |
Create a new stack container.
options | combination of initialization options. |
errno | will be set in error condition.
|
size_t qstack_setsize | ( | qstack_t * | stack, |
size_t | max | ||
) |
bool qstack_push | ( | qstack_t * | stack, |
const void * | data, | ||
size_t | size | ||
) |
qstack->push(): Pushes an element onto the top of this stack.
stack | qstack container pointer. |
data | a pointer which points data memory. |
size | size of the data. |
errno | will be set in error condition.
|
bool qstack_pushstr | ( | qstack_t * | stack, |
const char * | str | ||
) |
qstack->pushstr(): Pushes a string onto the top of this stack.
stack | qstack container pointer. |
data | a pointer which points data memory. |
size | size of the data. |
errno | will be set in error condition.
|
bool qstack_pushint | ( | qstack_t * | stack, |
int64_t | num | ||
) |
qstack->pushint(): Pushes a integer onto the top of this stack.
stack | qstack container pointer. |
num | integer data. |
errno | will be set in error condition.
|
void * qstack_pop | ( | qstack_t * | stack, |
size_t * | size | ||
) |
qstack->pop(): Removes a element at the top of this stack and returns that element.
stack | qstack container pointer. |
size | if size is not NULL, element size will be stored. |
errno | will be set in error condition.
|
char * qstack_popstr | ( | qstack_t * | stack | ) |
qstack->popstr(): Removes a element at the top of this stack and returns that element.
stack | qstack container pointer. |
errno | will be set in error condition.
|
int64_t qstack_popint | ( | qstack_t * | stack | ) |
qstack->popint(): Removes a integer at the top of this stack and returns that element.
stack | qstack container pointer. |
errno | will be set in error condition.
|
void * qstack_popat | ( | qstack_t * | stack, |
int | index, | ||
size_t * | size | ||
) |
qstack->popat(): Returns and remove the element at the specified position in this stack.
stack | qstack 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.
|
void * qstack_get | ( | qstack_t * | stack, |
size_t * | size, | ||
bool | newmem | ||
) |
qstack->get(): Returns an element at the top of this stack without removing it.
stack | qstack 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.
|
char * qstack_getstr | ( | qstack_t * | stack | ) |
qstack->getstr(): Returns an string at the top of this stack without removing it.
stack | qstack container pointer. |
errno | will be set in error condition.
|
int64_t qstack_getint | ( | qstack_t * | stack | ) |
qstack->getint(): Returns an integer at the top of this stack without removing it.
stack | qstack container pointer. |
errno | will be set in error condition.
|
void * qstack_getat | ( | qstack_t * | stack, |
int | index, | ||
size_t * | size, | ||
bool | newmem | ||
) |
qstack->getat(): Returns an element at the specified position in this stack without removing it.
stack | qstack 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 | will be set in error condition.
|
size_t qstack_size | ( | qstack_t * | stack | ) |
void qstack_clear | ( | qstack_t * | stack | ) |
bool qstack_debug | ( | qstack_t * | stack, |
FILE * | out | ||
) |