typedef LListElement StackElement; typedef LList Stack; The Stack data structure represents a stack and it is a front-end to the LList data structure. |
| Stack* stack_create(destroyfunc*
destroy, comparefunc* cmp) description: creates a new, empty stack. The destroy parameter is a pointer to a user-defined destroyfunc. This function will be called by stack_destroy to free dynamically allocated data. If the data to be inserted in the stack should not be freed, destroy should be set to NULL. The cmp parameter is a pointer to a user-defined comparefunc. This function will be used by the stack_element_is_member function to compare the the stack elements. If stack_element_is_member won't be necessary, cmp should be set to NULL. return value: a pointer to a new Stack data structure, or NULL if the allocation fails. since: YACLib 1.0 int stack_push(Stack* stack, const void* data) description: pushes an element onto the stack specified by stack. The new element will store a pointer to data. return value: 0 if the element could be pushed, -1 otherwise. since: YACLib 1.0 int stack_pop(Stack* stack, void** data) description: pops an element off the stack specified by stack. Upon return, data will receive the data pointer of the element poped. return value: 0 if the element could be poped, -1 otherwise. since: YACLib 1.0 void stack_remove_all(Stack* stack) description: removes all elements from the stack specified by stack. return value: none. since: YACLib 1.0 int stack_element_is_member(const Stack* stack, const void* data) description: searches for an element matching data in the stack specified by stack. returns value: 1 if an element matching data was found, 0 othrewise. since: YACLib 1.0 void stack_destroy(Stack* stack) description: destroys the stack specified by stack. It will remove all the elements from the stack and call the destroyfunc function passed to stack_create for each element as it is removed from the stack, provided destroy wasn't set to NULL. return value: none. since: YACLib 1.0 StackElement* stack_peek(const Stack* stack) description: macro that evaluates to the element at the top of the stack specified by stack. return value: the element at the top of stack. since: YACLib 1.0 StackElement* stack_botton(const Stack* stack) description: macro that evaluates to the element at the botton of the stack specified by stack. return value: the element at the botton of stack. since: YACLib 1.0 int stack_size(const Stack* stack) description: macro that evaluates to the number of elements of the stack specified by stack. return value: the number of elements of stack. since: YACLib 1.0 |