2019-07-02 04:06:21 +03:00
|
|
|
# Simple generic Stack
|
2017-12-08 20:00:49 +03:00
|
|
|
|
|
|
|
This is a modular generic stack data-structure. The stack is self growing.
|
|
|
|
|
|
|
|
### Content
|
|
|
|
|
|
|
|
* stack-Header file for import.
|
|
|
|
* stack.c implementation of the stack
|
2019-07-02 04:06:21 +03:00
|
|
|
* main.c framework program for testing.
|
|
|
|
* stack_linkedlist: Another stack implementation by linkedlist
|
2017-12-08 20:00:49 +03:00
|
|
|
|
|
|
|
You need to only import the **stack.h**
|
|
|
|
|
|
|
|
### Public interface
|
|
|
|
|
2020-04-08 13:30:07 +03:00
|
|
|
```c
|
|
|
|
void initStack();
|
|
|
|
```
|
2017-12-08 20:00:49 +03:00
|
|
|
|
|
|
|
Initializes the stack with a capacity of 10 elements.
|
|
|
|
|
2020-04-08 13:30:07 +03:00
|
|
|
```c
|
|
|
|
void push(void * object);
|
|
|
|
```
|
2017-12-08 20:00:49 +03:00
|
|
|
|
2019-07-02 04:06:21 +03:00
|
|
|
pushs the argument onto the stack
|
2017-12-08 20:00:49 +03:00
|
|
|
|
2020-04-08 13:30:07 +03:00
|
|
|
```c
|
|
|
|
void * pop();
|
|
|
|
```
|
2017-12-08 20:00:49 +03:00
|
|
|
|
|
|
|
pop: pops the top element of the stack from the stack.
|
|
|
|
|
|
|
|
assumes: stack not empty.
|
|
|
|
|
2020-04-08 13:30:07 +03:00
|
|
|
```c
|
|
|
|
int size();
|
|
|
|
```
|
2017-12-08 20:00:49 +03:00
|
|
|
|
|
|
|
gets the number of elements of the stack.
|
|
|
|
|
2020-04-08 13:30:07 +03:00
|
|
|
```c
|
|
|
|
int isEmpty();
|
|
|
|
```
|
2017-12-08 20:00:49 +03:00
|
|
|
|
|
|
|
returns 1 if stack is empty otherwise 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|