void push (STACK_p_t stack, String item) { if (isStackFull(*stack)) { printf("\n\tSTACK OVERFLOW!\n\n"); return; } *(stack->arr + ++(stack->tos)) = item; }
void Portrait::update(){ w = ofGetWidth(); h = ofGetHeight(); imgIndex++; if(imgIndex >= IMG_STACK_LENGHT) imgIndex = 0; if(FIRST_LOAD && isStackFull()){ FIRST_LOAD = false; load(); } if(!FIRST_LOAD){ if(tmpImg.bAllocated()){ img[loadingIndex].clone(tmpImg); loadingIndex++; if(loadingIndex >= IMG_STACK_LENGHT) loadingIndex = 0; load(); } } }
void push(loliObj* obj){ if(isStackFull()){ std::cout<<"Error: Stack Overflow!"<<std::endl; return; } loli_stack[obj_in_stack++] = *obj; }
void push (char ** stack, char * item, int *tos) { if (isStackFull (*tos)) { printf("\n\tSTACK OVERFLOW\n"); return; } (*tos) += 1; *(stack + (*tos)) = item; }
void test_9_check_isStackFull_when_the_stack_is_not_Full(){ int arr[] = {0,0,0,0,0}; int result; Stack intData = create_ints(5, arr); intData.top = -1; result = isStackFull(&intData); ASSERT(1 == result); }
int pushInStack(stack *s1,int *p) { if(isStackFull(s1)) return 0; s1->top++; s1->arr[s1->top] = p; return 1; }
int pushInStack(stack *s1,node * element) { if(isStackFull(s1)) return 0; s1->top++; s1->arr[s1->top] = element; return 1; }
void push(Stack S , int n){ struct LinkedListStack *s = GetStack(S); if(isStackFull(s)){ fprintf(stderr, "Stack Overflow! Cannot Push a thing right now\n"); return; } insert(&s->top,n); }
int main(int argc, const char * argv[]) { int tos = -1; char ** stack = (char **)calloc(SIZE, sizeof(char *)); int choice; do { printf("\n\t1. Push an element.\n\t2. Pop an element.\n\t3. Display current stack.\n\tAnything else for exit.\nEnter your choice: "); scanf(" %d", &choice); // scanf(" %s", &choice); if (choice == 1) { char * item = (char *)calloc(SIZE, sizeof(char)); printf("\n\tEnter element to be pushed: "); scanf(" %s", item); push(stack, item, &tos); if (!isStackFull(tos)) { printf("\nCurrent Stack: "); display(stack, tos); } } else if (choice == 2) { char * item = pop(stack, &tos); if (item != UNDERFLOW) { printf("\n\tPopped item = %s\n", item); printf("\nCurrent Stack: "); display(stack, tos); } } else if (choice == 3) { printf("\n\tCurrent Stack: "); display(stack, tos); } else exit(0); } while (choice == 1 || choice == 2 || choice == 3); return 0; }
int main() { FILE *fp; Pile pile; tInfo info; char op; printf("\t\t\tEjercicio 4 tp3 Pila estatica\n"); if(!openFile(&fp,"r+b",FILENAME,!CON_SIN_MSJ)) { createFile(); if(!openFile(&fp,"r+b",FILENAME,CON_SIN_MSJ)) return 0; } createStack(&pile); fread(&info,1,sizeof(tInfo),fp); while(!feof(fp) && !isStackFull(&pile)) { putInStack(&pile,&info); fread(&info,1,sizeof(tInfo),fp); } fclose(fp); op = menuOption(MSJ,OPTION); while(op != 'D') { switch(op) { case 'A': { newInfo(&info); if(putInStack(&pile, &info) == PILA_LLENA) puts("pila llena no se pudo cargar la nueva informacion"); break; } case 'B': { puts("Viendo tope de la pila: "); if(showTop(&pile,&info) != PILA_VACIA) showInfo(&info); else puts("Pila vacia, no se puede ver tope"); break; } case 'C': { puts("Sacando de pila..."); if(takeOfStack(&pile,&info) != PILA_VACIA) showInfo(&info); else puts("No se puede sacar de pila, pila vacia"); break; } } op = menuOption(MSJ,OPTION); } if(!openFile(&fp,"r+b",FILENAME,CON_SIN_MSJ)) { puts("Vaciando pila..."); emptyStack(&pile); return 0; } while(!isStackEmpty(&pile)) { takeOfStack(&pile,&info); putInTheEndFile(&fp,&info); } emptyStack(&pile); fclose(fp); return 0; }
void stack::push(int n){ if(!isStackFull()){ data[++top]=n; } }
bool push(Stack* p, int val) { if (!validate(p->pValidator, val) || isStackFull(p)) return false; p->pBuf[p->top++] = val; return true; }