Typedefs | |
| typedef arraystack_adt * | ArrayStack |
| Pointer to structure reprsenting a stack. | |
Functions | |
| ArrayStack | AS_New () |
| Creates a new stack. | |
| void | AS_Free (ArrayStack stack) |
| Destroys the specified stack. | |
| int | AS_Size (ArrayStack stack) |
| Returns the size of the stack. | |
| int | AS_Empty (ArrayStack stack) |
| Determines if the stack is empty or not. | |
| void | AS_Push (ArrayStack stack, void *el) |
| Adds an element to the top of the stack. | |
| void | AS_Pop (ArrayStack stack) |
| Removes an element from the top of the stack. | |
| void * | AS_Top (ArrayStack stack) |
Retrieves the data in the element at the top of the stack. The function returns the data in the element at the top of the stack but does not alter in any way the structure of the stack. However the actual data can be changed through the use of the void* pointer returned, which points to the memory location containing the data. | |
It contains functions for creating a stack, destroying it and all the typical operations on a stack (push, pop, top).
| typedef struct arraystack_adt* ArrayStack |
Pointer to structure reprsenting a stack.
The ArrayStack is implemented using an ArrayList . However, the underlying ArrayList should not be modified directly but only through the appropriate functions.
As is the case with the ArrayList element data is stored using a void* pointer. Thus, one should note there is no way to tell what kind of data is stored in the list or in a particular element.
| int AS_Empty | ( | ArrayStack | stack | ) |
Determines if the stack is empty or not.
The function actually returns the value of the expression Size==0.
| stack | the stack to be tested. |
-1 if the stack stack is NULL, 1 if the stack is empty, 0 otherwise. | void AS_Free | ( | ArrayStack | stack | ) |
Destroys the specified stack.
The function frees the memory used by the stack structure itself as well as the memory used by the data in the stack, so trying to access the data after the destruction of the stack (e.g. through a pointer) will most likely result in a Access violation / segfault.
| stack | ArrayStack representing the stack to be destroyed. |
| ArrayStack AS_New | ( | ) |
Creates a new stack.
The function creates a new array stack (stack implemented using an ArrayList ). Thus, the stack can grow to accomodate as many elements as needed.
| void AS_Pop | ( | ArrayStack | stack | ) |
Removes an element from the top of the stack.
The function removes the element at the top of the stack. Note that the data in that element is not freed, so that it can be further referenced.
| stack | the stack on which to perfom the operation |
| void AS_Push | ( | ArrayStack | stack, | |
| void * | el | |||
| ) |
Adds an element to the top of the stack.
The function adds the data specified by el to the top of the stack.
| stack | the stack to add data to. | |
| *el | pointer to a initialized memory location containing the data to be added at the top of the stack. |
| int AS_Size | ( | ArrayStack | stack | ) |
Returns the size of the stack.
The function returns the number of elements in the stack.
| stack | stack to be tested. |
| void* AS_Top | ( | ArrayStack | stack | ) |
Retrieves the data in the element at the top of the stack. The function returns the data in the element at the top of the stack but does not alter in any way the structure of the stack. However the actual data can be changed through the use of the void* pointer returned, which points to the memory location containing the data.
| stack | the stack on which to perform the operation |
NULL or empty, it returns NULL . Otherwise, it returns a pointer to the memory location where the data in the element at the top of the stack is stored.
1.5.1