// Some functions on linked lists, and a Node struct
// -- Short version for Lab 6.  only includes a few functions.
//   There is no "List" class here.  A linked list variable has type "Node *"
//   (that is, pointer to Node).
//
// Code by Ford and Topp; Modified by Claire Bono to make it consistent
// with some of the coding conventions we're using in CS 102:
//    -- made Node a struct, since it has public data
//        -- made all the data public
//        -- also elim NextNode func, since we can access next publicly.
//    -- changed format to start function names with lower case 
//    -- the text uses the name T for the type of an individual element
//        changed it to "ElmtType" here for clarity.
//    -- took out use of templates (we'll talk about them soon)
//        instead of template param T, we have typedef for ElmtType
//    -- changed name of function "Delete" to "deleteFirstOcc"
//        (because lower case version of this name is a reserved word in C++)

#include <iostream.h>
#include <stdlib.h>

typedef int ElmtType;

struct Node
{
    ElmtType data;
    Node *next;
    

      // constructor. initialize data and pointer members
    Node (const ElmtType& item, Node* ptrnext = NULL);

      // insert a node p after the current one
    void insertAfter(Node *p);

      // unlink the node following current and return its address
    Node *deleteAfter(void);
        
};

// allocate a node with data member item and pointer nextPtr
Node *getNode(const ElmtType& item, Node *nextPtr = NULL);

// insert item at the front of list
void insertFront(Node* & head, ElmtType item);

// used by printList
enum AppendNewline {noNewline,addNewline};

// print a linked list
void printList(Node *head, AppendNewline addnl = noNewline);

// delete all the nodes in the linked list
void clearList(Node * &head);

