Mercurial > hg > Papers > 2018 > ryokka-sigos
view Paper/src/stackimpl.cbc @ 12:e20725cd6d8a default tip
fix slides
author | ryokka |
---|---|
date | Mon, 21 May 2018 00:29:29 +0900 |
parents | a5facba1adbc |
children |
line wrap: on
line source
Stack* createSingleLinkedStack(struct Context* context) { struct Stack* stack = new Stack(); struct SingleLinkedStack* singleLinkedStack = new SingleLinkedStack(); stack->stack = (union Data*)singleLinkedStack; singleLinkedStack->top = NULL; stack->push = C_pushSingleLinkedStack; stack->pop = C_popSingleLinkedStack; stack->pop2 = C_pop2SingleLinkedStack; stack->get = C_getSingleLinkedStack; stack->get2 = C_get2SingleLinkedStack; stack->isEmpty = C_isEmptySingleLinkedStack; stack->clear = C_clearSingleLinkedStack; return stack; } __code clearSingleLinkedStack(struct SingleLinkedStack* stack,__code next(...)) { stack->top = NULL; goto next(...); } __code pushSingleLinkedStack(struct SingleLinkedStack* stack,union Data* data, __code next(...)) { Element* element = new Element(); element->next = stack->top; element->data = data; stack->top = element; goto next(...); }