Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the circular linked list specification here, implement the class constructor and destructor in c++ template struct Node; // forward reference /* Given: T is

Using the circular linked list specification here, implement the class constructor and destructor in c++

template

struct Node; // forward reference

/* Given: T is a type for which the operators "<" and "==" are defined either

an appropriate built-in type or a class that overloads these operators */

template

class Sorted

{

public:

// class constructor, destructor, and copy constructor

Sorted();

~Sorted();

Sorted(const Sorted & s);

void operator=(Sorted s);

bool IsFull() const; // Determines whether list is full

// Post: Function value = (list is full)

int GetLength() const; // Determines number of elements in list

// Post: Function value = number of elements in list

// the following operations have the pre/post

// condition that the list items are sorted

void RetrieveItem(T & itm, bool & found);

// gets list element whose key matches item's key, if present

// Pre: Key member of item is initialized

// Post: If there is an element someItem whose key matches

// item's key, then found = true and item is a copy of

// someItem; otherwise found = false and item is unchanged

// List is unchange

void InsertItem(T itm); // adds itm to list

// Pre: List is not full; itm is not in list

// Post: itm is in list

void DeleteItem(T itm);

// deletes the element whose key matches itm's key

// Pre: Key member of itm is initialized;

// One and only one element in list has a matching key

// Post: No element in list has a key matching itm's key

void ResetList();

//initializes current position for an iteration through list

// Post: Current position is prior to list

void GetNextItem(T & itm); // gets the next element in list

// Pre: Current position is defined;

// Element at current position is not last in list

// Post: Current position is updated to next position

// item is a copy of element at current position

private:

Node * listData;

int length;

Node * currentPos;

};

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago