1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#ifndef LINKEDLISTTYPE_H_INCLUDED
#define LINKEDLISTTYPE_H_INCLUDED
#include "linkedListIterator.h"
template<class Type>
class linkedListType
{
public:
const linkedListType<Type>& operator=
(const linkedListType<Type>&);
//overload assignment operator
void initializeList();
//Initialize list to empty state
//first = NULL, last = NULL, count = 0
bool isEmptyList() const;
//determine whether list is empty
//returns true if the list is empty
void print() const;
//output data
int length() const;
//return number of nodes from list
//value of count returned
void destroyList();
//function to return first element from list
//first = NULL, last = NULL, count = 0
Type front() const;
//returns first element of list
//if list is empty, program terminates
Type back() const;
//return last element of list
//if list is empty, program terminates
virtual bool search(const Type& searchItem) const = 0;
//PURE VIRTUAL FUNCTION, must be overridden
//returns true if item is in list, false if not
virtual void insertFirst(const Type& newItem) = 0;
//inset new item as beginning of list
//first points to new list, new item is
//inserted at beg. of list, last points
//to last node, count incremented
virtual void insertLast(const Type& newItem) = 0;
//insert new item at end of list
//first points to new list, new
//item instered at end of list and
//points to last
virtual void deleteNode(const Type& deleteItem) = 0;
//delete item from list
//count decremented by one, nodes set correctly
linkedListIterator<Type> begin();
//function to return an iterator at the
//begining of the linked list
//returns an iterator set to first
linkedListIterator<Type> end();
//function to return iterator type
//that points to end of linked list
linkedListType();
//defualt constructor
//list empty state
//first = NULL, last = NULL, count = 0
linkedListType(const linkedListType<Type>& otherList);
//copy constructor
~linkedListType();
//destructor
//deletes all nodes from list
protected:
int count; //stores amount of elements in list
nodeType<Type> *first; //pointer to the first node of the list
nodeType<Type> *last; //pointer to last node in list
private:
void copyList(const linkedListType<Type>& otherList);
//function to make a copy of other list
//copy of other list is created and assigned to current list
};
//function code here, not enough room to put it so i edited it out, but functions work.
#endif // LINKEDLISTTYPE_H_INCLUDED
|