// stack.h - public declarations for the stack

#ifndef __stack_h__
#define __stack_h__

#define STACK_DEBUG      0x01

typedef struct _Stack_ Stack;

//------------------------------------------------------------
// struct for the stack and access functions
struct _Stack_
{
  void **elements;
  void (**destructors)(void *element,
                       void (*error_handler)(int error_type,
                                             void *special));
  unsigned num_elements;
  unsigned num_elements_allocated;
  unsigned threshold_percentage;
};

Stack *newStack(void (*error_handler)(int error_type,
                                      void *special));
void deleteStack(Stack *stack,
                 void (*error_handler)(int error_type,
                                       void *special));
void setThresholdPercentage(Stack *stack,
                            unsigned threshold_percentage,
                            void (*error_handler)(
                              int error_type,
                              void *special));
unsigned  getNumElementsFromStack(Stack *stack,
                                  void (*error_handler)(
                                    int error_type,
                                    void *special));
void push(Stack *stack,void *element,
          void (*destructor)(void *element,
                             void (*err_handler)(int error_type,
                                                 void *special)),
          void (*error_handler)(int error_type,void *special));
void *pop(Stack *stack,
          void (*error_handler)(int error_type,void *special));
void swap(Stack *stack,
          void (*error_handler)(int error_type,void *special));
void clear(Stack *stack,
           void (*error_handler)(int error_type,void *special));
void *peek(Stack *stack,unsigned index,
           void (*error_handler)(int error_type,void *special));

#endif // __stack_h__

