5 #include "cgds/Stack.h"
7 void _stack_init(Stack
* stack
, size_t dataSize
)
9 stack
->dataSize
= dataSize
;
10 _vector_init(stack
->array
, dataSize
);
13 Stack
* _stack_new(size_t dataSize
)
15 Stack
* stack
= (Stack
*) safe_malloc(sizeof (Stack
));
16 _stack_init(stack
, dataSize
);
20 Stack
* stack_copy(Stack
* stack
)
22 Stack
* stackCopy
= (Stack
*) safe_malloc(sizeof (Stack
));
23 stackCopy
->dataSize
= stack
->dataSize
;
24 Vector
* arrayCopy
= vector_copy(stack
->array
);
25 stackCopy
->array
= arrayCopy
;
29 Bool
stack_empty(Stack
* stack
)
31 return vector_empty(stack
->array
);
34 UInt
stack_size(Stack
* stack
)
36 return vector_size(stack
->array
);
39 void _stack_push(Stack
* stack
, void* data
)
41 _vector_push(stack
->array
, data
);
44 void* _stack_top(Stack
* stack
)
46 return _vector_get(stack
->array
, vector_size(stack
->array
)-1);
49 void stack_pop(Stack
* stack
)
51 vector_pop(stack
->array
);
54 void stack_clear(Stack
* stack
)
56 vector_clear(stack
->array
);
59 void stack_destroy(Stack
* stack
)