(Latest Revision: Fri Oct 2 19:21 PDT 2015)

SOURCE FILE: ListT.h


// *********************************************************
// Header file ListT.h for the ADT list.
// Pointer-based implementation -- TEMPLATE VERSION
// *********************************************************
#ifndef my_LISTT_H 
#define my_LISTT_H 

#include <iostream.h>

        /* Note that the "T" referred to in both statements below
           is the same thing.  The syntax does not allow you to
           use the same symbol "T" to refer to two different data
           types.  "listNode" is a struct that contains "a T" in
           one of its fields.  "listClass" is a class of lists in
           which we can store objects of type "T."  */

template <class T> struct listNode;  // defined in ListT.cpp

template <class T> 
class listClass
{
  private:
     int          Size;
     listNode<T>* Head;

     listNode<T>* PtrTo(int Position) const;
     virtual void CopyListNodes(const listClass<T> & L) ;

  public:
  // constructors and destructor:
     listClass();

         /* Note that you have to add the "<T>" when using
            the name "listClass" as the type of a parameter in a
            function declaration.  However you do not use it in
            the name of a constructor or destructor. */

     listClass(const listClass<T>& L);
     virtual void MakeListEmpty() ;
     virtual ~listClass();

  // list operations:
     virtual bool ListIsEmpty() const;
     virtual int ListLength() const;
     virtual listClass<T>& operator= (const listClass<T>& Rhs) ;

     virtual void ListInsert(int NewPosition,  T NewItem,
                           bool& Success);
     virtual void ListDelete(int Position, bool& Success);
     virtual void ListRetrieve(int Position, T& DataItem,
                             bool& Success) const;
};  // end class

#include "ListT.cpp"           // include the implementation file

// End of header file.
#endif