Actual source code: stack.h

  1: /*$Id: stack.h,v 1.2 2001/04/10 19:37:38 bsmith Exp $*/
  2: /******************************************************************************
  3: File: stack.h
  4: -------------
  5:   This file provides an interface to a simple stack
  6:   abstraction.
  7: ******************************************************************************/
  8: #ifndef _stack_h
  9: #define _stack_h


 12: /******************************************************************************
 13: Type: stack_ADT
 14: ---------------
 15:   This line defines the abstract stack type as a pointer to
 16:   its concrete counterpart.  Clients have no access to the
 17:   underlying representation.
 18: ******************************************************************************/
 19: typedef struct stack_CDT *stack_ADT;



 23: /******************************************************************************
 24: Function: new_stack()

 26: Input : na
 27: Output: na
 28: Return: pointer to ADT.
 29: Description: This function allocates and returns an empty stack. 
 30: Usage: stack = new_stack();   
 31: ******************************************************************************/
 32: stack_ADT new_stack(void);



 36: /******************************************************************************
 37: Function: free_stack()

 39: Input : pointer to ADT.
 40: Output: na
 41: Return: na
 42: Description: This function frees the storage associated with stack but not any
 43: pointer contained w/in.
 44: Usage: free_stack(stack);
 45: ******************************************************************************/
 46: void free_stack(stack_ADT stack);



 50: /******************************************************************************
 51: Function: push()

 53: Input : pointer to ADT and pointer to object
 54: Output: na
 55: Return: na
 56: Description: This function adds obj to the top of the stack.
 57: Usage: push(stack, obj);
 58: ******************************************************************************/
 59: void push(stack_ADT stack, void *obj);



 63: /******************************************************************************
 64: Function: pop()  

 66: Input : pointer to ADT
 67: Output: na 
 68: Return: void * to element
 69: Description: This function removes the data value at the top of the stack
 70: and returns it to the client.  popping an empty stack is an error.
 71: Usage: obj = pop(queue, obj);
 72: ******************************************************************************/
 73: void *pop(stack_ADT stack);



 77: /******************************************************************************
 78: Function: len_stack()

 80: Input : pointer to ADT
 81: Output: na
 82: Return: integer number of elements
 83: Description: This function returns the number of elements in the stack.
 84: n = len_stack(queue);
 85: ******************************************************************************/
 86: int len_stack(stack_ADT stack);



 90: #endif