Question: 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

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!