[prev] [index] [next]

Example: Quack ADT (cont)

The operations are contained in a header file quack.h

typedef struct _node *Quack;

Quack createQuack(void);     // create and return Quack
void  push(int, Quack);      // put the given integer onto the quack
int   pop(Quack);            // pop and return the top element on the quack
int   isEmptyQuack(Quack);   // return 1 if Quack is empty, else 0
void  makeEmptyQuack(Quack); // remove all the elements on Quack
void  showQuack(Quack);      // print contents of Quack, from the top down

  • push() and pop() are the core functions making a quack what it is
  • we assume that the quack contains integers (could instead contain characters or structs)
  • The type Quack is a pointer to a struct node
    • but what struct node?
    • depends on how the quack is implemented
    • which we cannot see from the header file