comparison Paper/src/stackimpl.cbc @ 0:a5facba1adbc

first
author ryokka
date Fri, 13 Apr 2018 18:07:04 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a5facba1adbc
1 Stack* createSingleLinkedStack(struct Context* context) {
2 struct Stack* stack = new Stack();
3 struct SingleLinkedStack* singleLinkedStack = new SingleLinkedStack();
4 stack->stack = (union Data*)singleLinkedStack;
5 singleLinkedStack->top = NULL;
6 stack->push = C_pushSingleLinkedStack;
7 stack->pop = C_popSingleLinkedStack;
8 stack->pop2 = C_pop2SingleLinkedStack;
9 stack->get = C_getSingleLinkedStack;
10 stack->get2 = C_get2SingleLinkedStack;
11 stack->isEmpty = C_isEmptySingleLinkedStack;
12 stack->clear = C_clearSingleLinkedStack;
13 return stack;
14 }
15
16 __code clearSingleLinkedStack(struct SingleLinkedStack* stack,__code next(...)) {
17 stack->top = NULL;
18 goto next(...);
19 }
20
21 __code pushSingleLinkedStack(struct SingleLinkedStack* stack,union Data* data, __code next(...)) {
22 Element* element = new Element();
23 element->next = stack->top;
24 element->data = data;
25 stack->top = element;
26 goto next(...);
27 }