#ifndef LINKEDLIST_H_
#define LINKEDLIST_H_

#include "Collection.h"
#include "Stack.h"

/**
 * A structure for Linked List Nodes
 */
struct LinkNode {
  int data;
  LinkNode *next;
  LinkNode(int pData = 0, LinkNode *pNext = NULL) : data(pData), next(pNext) {}
};

/**
 * A basic implementation of our Collection ADT
 * and Stack ADT using a singly linked list.
 */
class LinkedList : public Collection, public Stack {
  LinkNode *head;
  
  public:
    LinkedList() : head(NULL) {};
    ~LinkedList();
    
    /**
     * Returns the count of the number of elements in the Collection
     */
    int size() const;
    
    /**
     * Adds the given integer value to the Collection. Placement index of
     * the newly added element is assumed to be first (index=0).
     */
    void add(int);
    
    /**
     * Returns the integer value of the first element of the Collection.
     */
    int first() const;
    
    /**
     * Returns the integer value at the given index in our LinkedList
     */
    int get(int) const;
    
    
    /**
     * Adds the given value at the given index in our LinkedList
     */
    void add(int, int);
    
    /**
     * Reverses the current LinkedList order
     */
    void reverse();
    
    /**
     * Returns the top element of the stack without removing it
     */
    int peek() const;
    
    /**
     * Removes (and returns) the top element of the stack
     */
    int pop();
    
    /**
     * Pushes the given value onto the top of the stack
     */
    void push(int);
    
    void print();
};

#endif /*LINKEDLIST_H_*/
