// list.h 
// unsorted link list implementation 

#ifndef _LIST
#define _LIST

#include "item3.h"
// Item.h must be provided by the user of this class.
// Item.h must contain the following definitions:
//   ItemType:  the definition of the objects in the list
//              ItemType must have the relational operator < , ==
//              ItemType must have a friend function <<


#include <iostream>
#include <cstddef>                     

using namespace std;


struct NodeType;


class ListType
{
public:
     ListType   ( );                     // Class constructor
     ListType   (const ListType& list); //Copy constructor
    ~ListType   ( );                     // Class destructor
     ListType& operator=(const ListType& other); // Assignment
     
    bool IsFull( ) const {return false;}
    // Function:  Determines whether list is full.
    // Pre:  List has been initialized.
    // Post: Function value = (list is full)

    bool IsEmpty( ) const;
    // Function:  Determines whether list is empty.
    // Pre:  List has been initialized.
    // Post: Function value = (list is empty)

    void MakeEmpty( );
    // Function:  Initializes list to empty state.
    // Post: List is empty.

    int Length() const;
    // Function: Determines the number of elements in list.
    // Pre:  List has been initialized.
    // Post: Function value = number of elements in list

    bool Retrieve(ItemType& item) const;
    // Function: Retrieves list item whose key matches item's key (if
    //           present).
    // Pre:  List has been initialized.
    //         Key member of item is initialized.
    // Post: If there is a list item someItem whose key matches
    //          item's key, then
    //           return val = true and item is a copy of
    //                                              someItem;
    //                  otherwise return val= false and item is unchanged.
    //  List is unchanged.

    bool Insert(const ItemType& item);
    // Function: Adds element to list.
    // Pre:  List has been initialized.
    //          List is not full.
    // Post: item is in list.

    bool Delete(const ItemType& item);
    // Function: Deletes the list item whose key matches item's key.
    // Pre:  List has been initialized.
    //          Key member of item is initialized.
    // Post: That item is no longer in list.

     bool IsPresent(const ItemType & item) const;
    // Function: Checks if item is in the list based on the key
    // Pre:  List has been initialized.
    //          Key member of item is initialized.
    // Post: If there is a list item someItem whose key matches
    //          item's key, then
    //                          return val = true
    //                  otherwise return val= false

    void SelSort();
    // Function: Sorts the list in ascending order
    // Pre:  List has been initialized
    // Post: List is sorted in ascending order based on key field(s).

     void Print() const;
     // Function: Prints the entire list to standard output
     // Pre:  List has been initialized
     // Post: List was printed to standard output
     
    void ResetList();
    // Function: Initializes current position for
    //           an iteration through the list.
    // Post: Current position is prior to list.

    void GetNextItem(ItemType&);
    // Function: Gets the next element in list.
    // Pre:  Current position is defined.
    //       Element at current position is not last in list.
    // Post: Current position is updated to next position.
    //       item is a copy of element at current position.


     

private:
    NodeType* head;
    NodeType* currentPos;
    int length;
};

#endif

