SLIDE 14 Advanced Programming Modular Programming in C 14
27
Instantiable ADTs
n The simple implementations of ADT are based
- n a set of global variables
n This is a singleton ADT solution. n Not suitable when several instances of the
same ADT are required, i.e. when an instantiable ADT is need
n The implementation needs to be adapted to
allow for multiple instances
28
Instantiable ADTs
n A singleton implementation of ADT can be
made instantiable by:
n Moving the variable used by the implementation into
a struct
n Adding a parameter to all ADT functions that specify
- n which instance it has to operate (a pointer to
that struct)
n Adding an initialization function to initialize the
struct’s fields