00001 /* CONVENTIONS: All data structures for stacks have the prefix */ 00002 /* "stk_" to prevent name conflicts. */ 00003 /* */ 00004 /* Function names: Each word in a function name begins with */ 00005 /* a capital letter. An example funcntion name is */ 00006 /* CreateRedTree(a,b,c). Furthermore, each function name */ 00007 /* should begin with a capital letter to easily distinguish */ 00008 /* them from variables. */ 00009 /* */ 00010 /* Variable names: Each word in a variable name begins with */ 00011 /* a capital letter EXCEPT the first letter of the variable */ 00012 /* name. For example, int newLongInt. Global variables have */ 00013 /* names beginning with "g". An example of a global */ 00014 /* variable name is gNewtonsConstant. */ 00015 00016 /* if DATA_TYPE is undefined then stack.h and stack.c will be code for */ 00017 /* stacks of void *, if they are defined then they will be stacks of the */ 00018 /* appropriate data_type */ 00019 00020 #ifndef DATA_TYPE 00021 #define DATA_TYPE void * 00022 #endif 00023 00024 typedef struct stk_stack_node { 00025 DATA_TYPE info; 00026 struct stk_stack_node * next; 00027 } stk_stack_node; 00028 00029 typedef struct stk_stack { 00030 stk_stack_node * top; 00031 stk_stack_node * tail; 00032 } stk_stack ; 00033 00034 /* These functions are all very straightforward and self-commenting so */ 00035 /* I didn't think additional comments would be useful */ 00036 stk_stack * StackJoin(stk_stack * stack1, stk_stack * stack2); 00037 stk_stack * StackCreate(); 00038 void StackPush(stk_stack * theStack, DATA_TYPE newInfoPointer); 00039 void * StackPop(stk_stack * theStack); 00040 int StackNotEmpty(stk_stack *); 00041