00001
00015
00016 #include <stdio.h>
00017 #include "epDefs.h"
00018 #include "epStack.h"
00019 #include "epList.h"
00020
00021
00037 epStack_t *epStack_create(int (*elementDeallocatorFunction)(void *elt))
00038 {
00039 _DEBUG2("entering...");
00040 00041 00042
00043 return(epList_create(_STACK_DIR, elementDeallocatorFunction));
00044 }
00045
00055 int epStack_destroy(epStack_t *stack)
00056 {
00057 _DEBUG2("entering...");
00058 00059 00060
00061 return(epList_destroy(stack));
00062 }
00063
00074 int epStack_push(epStack_t *stack, const void *elt)
00075 {
00076 _DEBUG2("entering...");
00077 00078 00079
00080
00081 return(epList_put(stack, 0, elt));
00082 }
00083
00093 void *epStack_pop(epStack_t *stack)
00094 {
00095 _DEBUG2("entering...");
00096 00097 00098
00099
00100 return(epList_get(stack, 0, _true));
00101 }
00102
00111 int epStack_size(epStack_t *stack)
00112 {
00113 _DEBUG2("entering...");
00114 00115 00116
00117 return(epList_size(stack));
00118 }
00119
00129 boolean_t epStack_isEmpty(epStack_t *stack)
00130 {
00131 _DEBUG2("entering...");
00132 00133 00134
00135 return(epList_isEmpty(stack));
00136 }
00137
00149 int epStack_setElementPrintFunction(
00150 epStack_t *stack,
00151 char *(*elementPrintFunction)(void *elt))
00152 {
00153 _DEBUG2("entering...");
00154 00155 00156
00157 return(epList_setElementPrintFunction(stack, elementPrintFunction));
00158 }
00159
00173 int epStack_printIt(epStack_t *stack, char *title)
00174 {
00175 int i;
00176
00177 _DEBUG2("entering...");
00178 _IF_TRUE_RETURN(stack == NULL, 0, -1);
00179
00180 if(title == NULL)
00181 { fprintf(stdout, "- Stack -----------------------------\n"); }
00182 else
00183 {
00184 fprintf(stdout, "- Stack - %s ", title);
00185 for(i = 0; i < (26 - strlen(title)); fprintf(stdout, "-"), i++);
00186 fprintf(stdout, "\n");
00187 }
00188
00189 fprintf(stdout, " * number of Elements: %2d\n", stack->numOfElements);
00190
00191 epList_printElements(stack);
00192 fprintf(stdout, "- End Stack -------------------------\n");
00193 _RETURN(0);
00194 }