Question: #ifndef H _ unorderedArrayListType #define H _ unorderedArrayListType #include arrayListType.h template class unorderedArrayListType: public arrayListType { public: void insertAt ( int location, const elemType&
#ifndef HunorderedArrayListType
#define HunorderedArrayListType
#include "arrayListType.h
template
class unorderedArrayListType: public arrayListType
public:
void insertAtint location, const elemType& insertItem;
void insertEndconst elemType& insertItem;
void replaceAtint location, const elemType& repItem;
int seqSearchconst elemType& searchItem const;
void removeconst elemType& removeItem;
unorderedArrayListTypeint size ;
Constructor
;
template
void unorderedArrayListType::insertEnd
const elemType& insertItem
if thislength thismaxSizethe list is full
cout "Cannot insert in a full list." endl;
else
thislistthislength insertItem; insert the item at the end
thislength; increment the length
end insertEnd
template
int unorderedArrayListType::seqSearch
const elemType& searchItem const
int loc;
bool found false;
for loc ; loc thislength; loc
if thislistloc searchItem
found true;
break;
if found
return loc;
else
return ;
end seqSearch
template
void unorderedArrayListType::remove
const elemType& removeItem
int loc;
if thislength
cout "Cannot delete from an empty list." endl;
else
loc seqSearchremoveItem;
if loc
thisremoveAtloc;
else
cout "The item to be deleted is not in the list."
endl;
end remove
template
void unorderedArrayListType::replaceAtint location,
const elemType& repItem
if location location thislength
cout "The location of the item to be
"replaced is out of range." endl;
else
thislistlocation repItem;
end replaceAt
template
void unorderedArrayListType::insertAtint location, const elemType& insertItem
if location location thismaxSize
std::cout "The position of the item to be inserted is out of range." std::endl;
else if thislength thismaxSize
std::cout "Cannot insert into a full list." std::endl;
else
for int i thislength; i location; i
thislisti thislisti ; Shift elements right
thislistlocation insertItem;
thislength; Increment list size
template
unorderedArrayListType::
unorderedArrayListTypeint size
: arrayListTypesize
end constructor
#endif HunorderedArrayListType
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
