-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.h
executable file
·43 lines (36 loc) · 1.74 KB
/
stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "misc.h"
/* CONVENTIONS: All data structures for stacks have the prefix */
/* "stk_" to prevent name conflicts. */
/* */
/* Function names: Each word in a function name begins with */
/* a capital letter. An example funcntion name is */
/* CreateRedTree(a,b,c). Furthermore, each function name */
/* should begin with a capital letter to easily distinguish */
/* them from variables. */
/* */
/* Variable names: Each word in a variable name begins with */
/* a capital letter EXCEPT the first letter of the variable */
/* name. For example, int newLongInt. Global variables have */
/* names beginning with "g". An example of a global */
/* variable name is gNewtonsConstant. */
/* if DATA_TYPE is undefined then stack.h and stack.c will be code for */
/* stacks of void *, if they are defined then they will be stacks of the */
/* appropriate data_type */
#ifndef DATA_TYPE
#define DATA_TYPE void *
#endif
typedef struct stk_stack_node {
DATA_TYPE info;
struct stk_stack_node * next;
} stk_stack_node;
typedef struct stk_stack {
stk_stack_node * top;
stk_stack_node * tail;
} stk_stack ;
/* These functions are all very straightforward and self-commenting so */
/* I didn't think additional comments would be useful */
stk_stack * StackJoin(stk_stack * stack1, stk_stack * stack2);
stk_stack * StackCreate();
void StackPush(stk_stack * theStack, DATA_TYPE newInfoPointer);
void * StackPop(stk_stack * theStack);
int StackNotEmpty(stk_stack *);