46 lines
993 B
C
46 lines
993 B
C
|
/*
|
||
|
*
|
||
|
* stack.h
|
||
|
*
|
||
|
* DO NOT MOFIFY OR SUBMIT THE CODE IN THIS FILE
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#ifndef STACK_H
|
||
|
#define STACK_H
|
||
|
|
||
|
|
||
|
struct Node
|
||
|
{
|
||
|
int data; /* Data member of node structure */
|
||
|
struct Node* nextPtr; /* Address of next node structure variable in the sequence */
|
||
|
};
|
||
|
|
||
|
extern void Print(struct Node* headPtr);
|
||
|
/* Print(...) : outputs the current contents of the stack top to bottom separated by spaces */
|
||
|
|
||
|
|
||
|
extern uint32_t Size(struct Node* headPtr);
|
||
|
/* Size(...) : returns the number of nodes currently stored in the stack */
|
||
|
|
||
|
|
||
|
extern void Push(struct Node** headPtr, int value);
|
||
|
/* Push(...) : adds a new node containing value to the top of the stack assuming stack is not full */
|
||
|
|
||
|
|
||
|
extern int Pop(struct Node** headPtr);
|
||
|
/* Pop(...) : removes and frees node from top of stack, returning the data from the removed node,
|
||
|
* assuming the stack is not empty
|
||
|
*/
|
||
|
|
||
|
|
||
|
extern void Clear(struct Node** headPtr);
|
||
|
/* Clear(...) : removes and frees all nodes from stack */
|
||
|
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|
||
|
|
||
|
|