#ifndef _stack_h_
#define _stack_h_

/**
 * This structure will represent one node in the Stack.
 * @menber mData The actual data the user interacts with and is concerned about.
 * @member mPrev A pointer to the previous node in the Stack.
 * @member mNext A pointer to the next node in the Stack.
 **/
struct StackNodeStruct
{
  void *mData;
  struct StackNodeStruct *mPrev, *mNext;
};
typedef struct StackNodeStruct StackNode;

/**
 * This structure will represent the Stack.
 * @member mSize The current size of the stack.
 * @member mMaxSize The maximums size the stack can be.  If this is -1, the stack is infinite in size.
 * @member mTop The top of the stack( last element inserted ).
 * @member mBottom The bottom of the stack( first element inserted ).
 * @member mDeleteData A pointer to the function that handles deleting the node's data.
 * @member mSetNodeData A pointer to the function that handles setting up a node.
 **/
struct StackStruct
{
  int mSize;
  int mMaxSize;
  StackNode *mTop, *mBottom;
  void (*mDeleteData)( void* );
  void *(*mSetNodeData)( void* );
};
typedef struct StackStruct Stack;

Stack *newStack( int maxSize, void (*deleteData)( void* ), void *(*setNodeData)( void* ) );
void delStack( Stack *stack );
int push( void *data, Stack *stack );

/**
 * This method acts similiarly to push but with a caveat.  It will push the new data into the
 * stack iff it compares better than some node currently in the stack.  In the event that it
 * does score better, the lowest node in the stack, mBottom, will be removed.
 * @param compare The method of comparison.
 * @param data The data to add to the stack.
 * @param stack The stack to add the data to.
 *
 **/
int pushWithScore( float (*compare)(void*, void*), void *data, Stack *stack );


#endif
