Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the h.file to output with main #pragma once template class List { struct ListNode { ListNode() { } T mData; ListNode* mPrev; ListNode* mNext;

image text in transcribed

Complete the h.file to output with main

#pragma once template class List { struct ListNode { ListNode() { } T mData; ListNode* mPrev; ListNode* mNext; };

ListNode* mHead; ListNode* mTail; mutable T mUndefined; int mSize = 0;

public: List() { // Getting Head and Tail correct is not part of the Big 3. It is hella mega required no matter what. //mHead = nullptr; //mTail = nullptr;// bleh. Full of crash. mHead = new ListNode; mTail = new ListNode; mHead->mNext = mTail; mHead->mPrev = nullptr; mTail->mPrev = mHead;// This RULES. We always know we have 2 nodes, so we never have to check for null. mTail->mNext = nullptr; } List( const List& tOther ) { } List& operator = ( const List& tRHS ) { } ~List() { }

void PushFront( const T& tWhat ) { } void PopFront() { } T& Front() { return mHead->mNext->mData; }

void PushBack( const T& tWhat ) { } void PopBack() { } T& Back() { return undefined; }

int Size() const { return 0; } void Clear() { }

T& At( int tWhere ) const { return mUndefined;

}

/////////////////////////////////////////////////////////////////// // Iterators class Iterator { friend List;

ListNode* mCurrent; T mUndefined; public: Iterator( ListNode* tStart ) { } T& GetData() { return mUndefined; } void Next()// As in "Move to the next item please" { } bool IsEqual( const Iterator& rhs ) { return false; } };

Iterator Insert( Iterator tWhere, const T& tWhat ) { } Iterator Erase( Iterator tWhere ) { } Iterator Begin() { // First good data return Iterator( nullptr ); } Iterator End() { // First Bad data return Iterator( nullptr ); } };

Main.cpp

// ListStart.cpp : This file contains the 'main' function. Program execution begins and ends there. //

#include #include "List.h" //#define DEBUGDEBUG

using namespace std;

int main() {

#ifdef DEBUGDEBUG int d; d = 9; d++; #endif

List tSomeInts;

tSomeInts.PushBack( 14 ); tSomeInts.PushBack( 1 ); tSomeInts.PushBack( 54 ); tSomeInts.PushBack( 25 );

List tIntCopy = tSomeInts;

tSomeInts.PopBack(); cout

cout

cout ::Iterator iter = tSomeInts.Begin(); !iter.IsEqual(tSomeInts.End()); iter.Next()) { cout Like I did for vector, I have uploaded the (required) beginning to this assignment. And like vector, just finish it. Please note though that the test file I've given does not have everything in it. And a template function that isn't called gets deleted. So you need to write a good test file. I'll only grade the list though. Don't worry though, this is the last "write ADT from scratch" assignment. Dynamic nodes are super important so you get this homework. But after this you'll be debugging or optimizing instead of writing from scratch. And yes, "Like vector" means no new properties and no breaking unbreakable rules and you have to use my file. I shouldn't have to say those every time, like I shouldn't have to tell you to not eat glass. The assignment is to finish this file. Big O measurements: Copy: O(n) Assign O(n) Destruct: 0(n) Push: 0(1) Pop: 0(1) Back/Front: 0(1) Size: 0(1) Clear: O(n) At: O(n) Insert: 0(1) Erase: 0(1) Begin: 0(1) End: 0(1) Like I did for vector, I have uploaded the (required) beginning to this assignment. And like vector, just finish it. Please note though that the test file I've given does not have everything in it. And a template function that isn't called gets deleted. So you need to write a good test file. I'll only grade the list though. Don't worry though, this is the last "write ADT from scratch" assignment. Dynamic nodes are super important so you get this homework. But after this you'll be debugging or optimizing instead of writing from scratch. And yes, "Like vector" means no new properties and no breaking unbreakable rules and you have to use my file. I shouldn't have to say those every time, like I shouldn't have to tell you to not eat glass. The assignment is to finish this file. Big O measurements: Copy: O(n) Assign O(n) Destruct: 0(n) Push: 0(1) Pop: 0(1) Back/Front: 0(1) Size: 0(1) Clear: O(n) At: O(n) Insert: 0(1) Erase: 0(1) Begin: 0(1) End: 0(1)

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago