Directory README

Version 1.0 (switch between implementations at link time)

The generic code which is oblivious to the data structure which implements the stack; can be gcc -c compiled with unresolved external functions new_stack(), delete_stack()
main.c.html
stack.h.html
stack.c.html (implements print_stack())

array_stack.c.html the array stack implementation of new_stack(), delete_stack()

list_stack.c.html the list stack implementation of new_stack(), delete_stack()

By linking gcc main.o stack.o array_stack.o (make a.out) or gcc main.o stack.o list_stack.o (make a2.out), one gets runnable binary files.

Version 2.0 (switch between implementations at compile and link time)

The data structure specific implementations array_stack_without_newstack.c and list_stack_without_newstack.c have global variables empty_arr_stack and empty_list_stack, whose (*clone)()'s are used to create new stacks of generic type stack. The generic stack structure type has an additional function pointer (*delete_stack)(), with which the clones are deleted.
array_stack_without_newstack.c.html
list_stack_without_newstack.c.html
stack_with_delete.h.html
stack_with_delete.c.html the generic print_stack function

Optionally, one can link to a data structure specific new_stack()
newstack_arr.c.html
newstack_list.c.html

main2.c.html tests software design: clones both array and list empty arrays as stacks; uses the function wrapper new_arr_stack() to clone an array stack; and uses a new_stack function which is associated to a data structure at link time. The make command is make a3.out NEWSTACK=newstack_arr or make a3.out NEWSTACK=newstack_list

Makefile.html
index.html