Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When you use a templated type in C++ ALL templated code must be done in the .h file. This means that ALL of your methods

When you use a templated type in C++ ALL templated code must be done in the .h file. This means that ALL of your methods will be defined in the .h file as well as your class. You should still forward declare Classes above then Methods below. Your .h file should have your LinkedList class and your Node class and the method definitions for both. Remember to use your :: operator correctly. Feel free to use friendship if needed.

You will create a Linked List Class and a Node Class/Struct The Linked List should contain the following methods in its public interface:

? Constructor

? Destructor

? AddToFront(T data) create a node containing T data and add it to the front of the list

? AddToEnd(T data) create a node containing T data and add it to eh end of the list

? AddAtIndex(T data, int index) create a node containing T data and add it to the list at index, return boolean for success or failure (optional: you could also return an integer with failure codes since this method can fail multiple ways)

? NextNode Move the current pointer to the next node, wraps to front if it navigates past the end ? InsertAfterCurrent(T data) Create a node containing T data and insert it after wherever the current pointer is pointing

? RemoveCurrent() Delete the current item and return its contents

? RemoveAtIndex(int index) delete the index # node in the list and return its contents

? RemoveFromFront() Delete first item and return its contents

? RemoveFromEnd() Delete last item and return its contents

? RemoveFirst(T data) find first instance of T data and remove it

? RemoveAll(T data) find each instance of T data and remove it

? ElementExists(T data) Returns a T/F if element exists in list

? Find(T data) Look for data in the list, return a pointer to its node

? IndexOf(T data) returns an index of the item in the list (zero-based)

? RetrieveFront returns the data contained in the first node, does not delete it

? RetrieveEnd returns the data contained in the last node, does not delete it

? Retrieve(int index) returns the data contained in node # index, does not delete it, returns null if index is out of bounds or data does not exist

? ToArray Create an array from the contents of the list and return it

? Empty Empty out the list, delete everything

? Length How many elements are in the list More methods private or public should be created as needed to facilitate the functionality of the Interface methods.

If you feel your list needs more functionality, feel free to create it.

Node Class

? Constructor

? Destructor

? Getters & Setters

The node class should be fairly rudimentary. It should be templated so you can store anything in it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago