Question: #ifndef _LINKED_LIST #define _LINKED_LIST #include ListInterface.h #include Node.h #include PrecondViolatedExcep.h template class LinkedList : public ListInterface { private: Node * headPtr; // Pointer to first

#ifndef _LINKED_LIST

#define _LINKED_LIST

#include "ListInterface.h"

#include "Node.h"

#include "PrecondViolatedExcep.h"

template

class LinkedList : public ListInterface

{

private:

Node* headPtr; // Pointer to first node in the chain;

// (contains the first entry in the list)

int itemCount; // Current count of list items

// Locates a specified node in this linked list.

// @pre position is the number of the desired node;

// position >= 1 and position <= itemCount.

// @post The node is found and a pointer to it is returned.

// @param position The number of the node to locate.

// @return A pointer to the node at the given position.

Node* getNodeAt(int position) const;

public:

LinkedList();

LinkedList(const LinkedList& aList);

virtual ~LinkedList();

bool isEmpty() const;

int getLength() const;

bool insert(int newPosition, const ItemType& newEntry);

bool remove(int position);

void clear();

/** @throw PrecondViolatedExcep if position < 1 or

position > getLength(). */

ItemType getEntry(int position) const throw(PrecondViolatedExcep);

/** @throw PrecondViolatedExcep if position < 1 or

position > getLength(). */

void setEntry(int position, const ItemType& newEntry)

throw(PrecondViolatedExcep);

};

The following will need to be modified:

- LinkedList.h: add a new Node* called tailPtr which points to the last item in the list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!