Mercurial > hg > Papers > 2018 > hamase_midterm
view midterm/src/SingleLinkedStack.cbc @ 4:3a41130a00bd default tip
add reference
author | Yuki HAMASE <e155718@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 16 Nov 2018 16:16:20 +0900 |
parents | c9b5432397b7 |
children |
line wrap: on
line source
__code pushSingleLinkedStack(struct Single LinkedStack* stack,union Data* data, __code next(...)) { Element* element = new Element(); element->next = stack->top; element->data = data; stack->top = element; goto next(...); } __code popSingleLinkedStack(struct Single LinkedStack* stack, __code next(union Data* data, ...)) { if (stack->top) { data = stack->top->data; stack->top = stack->top->next; } else { data = NULL; } goto next(data, ...); } __code pop2SingleLinkedStack(struct SingleLinkedStack* stack, __code next(union Data* data, union Data* data1, ...)) { if (stack->top) { data = stack->top->data; stack->top = stack->top->next; } else { data = NULL; } if (stack->top) { data1 = stack->top->data; stack->top = stack->top->next; } else { data1 = NULL; } goto next(data, data1, ...); }