<p class=\"NL\">Implement the following specification of UnsortedType using a ci
ID: 3638163 • Letter: #
Question
<p class="NL">Implement the following specification of UnsortedType using a circular linked list as the implementation structure.</p><p class="CP"> </p>
<p class="CP">template<class ItemType></p>
<p class="CP">structNodeType;</p>
<p class="CP"> </p>
<p class="cp0">/* Assumption:  ItemType is a type for which the operators</p>
<p class="cp0">"<" and "==" are defined—either an appropriate built-in type or a class that overloads these operators. */</p>
<p class="CP"> </p>
<p class="CP">template<class ItemType></p>
<p class="CP">classUnsortedType</p>
<p class="CP">{</p>
<p class="CP">public:</p>
<p class="CP">  // Class constructor, destructor, and copy constructor</p>
<p class="CP">UnsortedType();</p>
<p class="CP">  ~UnsortedType();</p>
<p class="CP">UnsortedType(constUnsortedType<ItemType>&);</p>
<p class="CP"> </p>
<p class="CP">void operator=(UnsortedType<ItemType>);</p>
<p class="CP"> </p>
<p class="CP">boolIsFull() const;</p>
<p class="CP">  // Determines whether list is full.</p>
<p class="CP">  // Post: Function value = (list is full)</p>
<p class="CP"> </p>
<p class="CP">intGetLength() const;</p>
<p class="CP">  // Determines the number of elements in list.</p>
<p class="CP">  // Post: Function value = number of elements in list.</p>
<p class="CP"> </p>
<p class="CP">voidRetrieveItem(ItemType& item, bool& found);</p>
<p class="CP">  // Retrieves list element whose key matches item's key</p>
<p class="CP">  // (if present).</p>
<p class="CP">  // Pre:  Key member of item is initialized.</p>
<p class="CP">  // Post: If there is an element someItem whose key matches </p>
<p class="CP">  //     item's key, then found = true and item is a copy of</p>
<p class="CP">  //     someItem; otherwise found = false and item is</p>
<p class="CP">  //     unchanged.</p>
<p class="CP">  //     List is unchanged.</p>
<p class="CP"> </p>
<p class="CP"> </p>
<p class="CP">voidInsertItem(ItemType item);</p>
<p class="CP">  // Adds item to list.</p>
<p class="CP">  // Pre:  List is not full.</p>
<p class="CP">  //       item is not in list.</p>
<p class="CP">  // Post: item is in list.</p>
<p class="CP"> </p>
<p class="CP">voidDeleteItem(ItemType item);</p>
<p class="CP">  // Deletes the element whose key matches item's key.</p>
<p class="CP">  // Pre:  Key member of item is initialized.</p>
<p class="CP">  //       One and only one element in list has a key matching</p>
<p class="CP">  //       item's key.</p>
<p class="CP">  // Post: No element in list has a key matching item's key.</p>
<p class="CP"> </p>
<p class="CP">voidResetList();</p>
<p class="CP">  // Initializes current position for an iteration through the</p>
<p class="CP">  // list.  </p>
<p class="CP">  // Post: Current position is prior to list.</p>
<p class="CP"> </p>
<p class="CP">voidGetNextItem(ItemType&);</p>
<p class="CP">  // Gets the next element in list.</p>
<p class="CP">  // Pre:  Current position is defined.</p>
<p class="CP">  //       Element at current position is not last in list.</p>
<p class="CP">  // Post: Current position is updated to next position.</p>
<p class="CP">  //       item is a copy of element at current position.</p>
<p class="CP"> </p>
<p class="CP">private:</p>
<p class="CP">NodeType<ItemType>* listData;</p>
<p class="CP">int length;</p>
<p class="CP">NodeType<ItemType>* currentPos;</p>
<p class="CP">};</p>
<h2>Deliverables</h2>
<ul>
<li>A listing of the specification and implementation files for UnsortedType</li>
<li>A listing of the driver program for your test plan</li>
<li>A listing of the test plan as input to the driver.</li>
<li>A listing of the output from the driver.</li>
</ul>
<p> </p>
<p></p>
Explanation / Answer
Hi, my fiend here is the circular linked class u can edit the way u want coz i can`t understand what is written in the question above if u need more help message me PLEASE RATE #include using namespace std; struct nodeType { char info; nodeType *link; }; class linkedListType { public: linkedListType() { head=new nodeType; head=0; } ~linkedListType() { destroyList(); } void insertFirst(char val) { nodeType *c; c=new nodeType; c->info=val; c->link=0; if(head==0) { head=c; head->link=head; } else { nodeType *p; p=head; while(p->link!=head) p=p->link; c->link=head->link; head=c; p->link=head; } } void insertLast(char val) { nodeType *p; p=new nodeType; p->info=val; p->link=head; if(head==0) { head=p; head->link=head; } else { nodeType *c; c=new nodeType; c=head; while(c->link!=head) c=c->link; c->link=p; } } void insertAfter(int loc,char val) { int count=0; nodeType *p; p=new nodeType; p->info=val; p->link=0; if(head==0) { head=p; head->link=head; } else { nodeType *c; c=head; while(countlink!=0) { c=c->link; count++; } if(c->link==head) { p->link=head; c->link=p; } else { p->link=c->link; c->link=p; } } } void insertBefore(int loc,char val) { nodeType *p; p=new nodeType; int count=0; p->info=val; p->link=0; if(head==0) { head=p; head->link=head; } else if(loc==0) insertFirst(val); else { nodeType *c=head; while(countlink; count++; } p->link=c->link; c->link=p; } } void initializeList() { destroyList(); } void destroyList() { nodeType *q; int count=0; int len=length(); if(head!=0) { while(count!=len) { q=head; head=head->link; delete q; count++; } } } bool isEmpty() { return (head == 0); } void print() { nodeType *curent=head; while(curent->link != head) { cout link; return (curent->info); } protected: nodeType *head; public: void copyList(const linkedListType &cf) { nodeType *p; nodeType *c; c=cf.head; if(cf.head==0) head=0; else { head=new nodeType; p=head; p->info=c->info; p->link=p; c=c->link; head=p; while(c!=cf.head) { p->link=new nodeType; p=p->link; p->info=c->info; p->link=0; c=c->link; } p->link=head; } } }; int main() { linkedListType obj1; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.