00001
00002
00003
00004
00005
00006
00007 #ifndef STACK_H
00008 #define STACK_H
00009 typedef struct
00010 {
00011 int *S;
00012 int Top,
00013 Size;
00014 }
00015 stack;
00016 typedef stack *stackP;
00017 stackP sp_New (int);
00018 void sp_Free (stackP *);
00019 int sp_Copy (stackP,
00020 stackP);
00021
00022 #ifndef SPEED_MACROS
00023 int sp_ClearStack (stackP);
00024 int sp_IsEmpty (stackP);
00025 int sp_NonEmpty (stackP);
00026 int sp_Push (stackP,
00027 int);
00028 int sp_Push2 (stackP,
00029 int,
00030 int);
00031
00032 #define sp_Pop(theStack, a) sp__Pop(theStack, &(a))
00033 #define sp_Pop2(theStack, a, b) sp__Pop2(theStack, &(a), &(b))
00034 int sp__Pop (stackP,
00035 int *);
00036 int sp__Pop2 (stackP,
00037 int *,
00038 int *);
00039
00040 #else
00041
00042 #define sp_ClearStack(theStack) theStack->Top=0
00043
00044 #define sp_IsEmpty(theStack) !theStack->Top
00045 #define sp_NonEmpty(theStack) theStack->Top
00046
00047 #define sp_Push(theStack, a) theStack->S[theStack->Top++] = a
00048 #define sp_Push2(theStack, a, b) sp_Push(theStack, a); sp_Push(theStack, b)
00049
00050 #define sp_Pop(theStack, a) a=theStack->S[--theStack->Top]
00051 #define sp_Pop2(theStack, a, b) sp_Pop(theStack, b);sp_Pop(theStack, a)
00052
00053 #endif
00054
00055 #endif