Question: arrayListType.h ----------------------------- template class elemType> bool arrayListType ::isEmpty() const { return (length == 0); } template class elemType> bool arrayListType ::isFull() const { return (length


arrayListType.h
-----------------------------


template class elemType>
bool arrayListType
{
return (length == 0);
}
template class elemType>
bool arrayListType
{
return (length == maxSize);
}
template class elemType>
int arrayListType
{
return length;
}
template class elemType>
int arrayListType
{
return maxSize;
}
template class elemType>
void arrayListType
{
for (int i = 0; i
cout
cout
}
template class elemType>
bool arrayListType
(int location, const elemType& item) const
{
return (list[location] == item);
}
template class elemType>
void arrayListType
(int location, const elemType& insertItem)
{
if (location = maxSize)
cerr
else
if (length >= maxSize) //list is full
cerr
else
{
for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at the
length++; //increment the length
}
} //end insertAt
template class elemType>
void arrayListType
{
if (length >= maxSize) //the list is full
cerr
else
{
list[length] = insertItem; //insert the item at the end
length++; //increment the length
}
} //end insertEnd
template class elemType>
void arrayListType
{
if (location = length)
cerr
else
{
for (int i = location; i
list[i] = list[i+1];
length--;
}
} //end removeAt
template class elemType>
void arrayListType
(int location, elemType& retItem) const
{
if (location = length)
cerr
else
retItem = list[location];
} //end retrieveAt
template class elemType>
void arrayListType
(int location, const elemType& repItem)
{
if (location = length)
cerr
else
list[location] = repItem;
} //end replaceAt
template class elemType>
void arrayListType
{
length = 0;
} //end clearList
template class elemType>
int arrayListType
{
int loc;
bool found = false;
for (loc = 0; loc
if (list[loc] == item)
{
found = true;
break;
}
if (found)
return loc;
else
return -1;
} //end seqSearch
template class elemType>
void arrayListType
{
int loc;
if (length == 0) //list is empty
list[length++] = insertItem; //insert the item and
//increment the length
else if (length == maxSize)
cerr
else
{
loc = seqSearch(insertItem);
if (loc == -1) //the item to be inserted
//does not exist in the list
list[length++] = insertItem;
else
cerr
}
} //end insert
templateclass elemType>
void arrayListType
{
int loc;
if (length == 0)
cerr
else
{
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
else
cout
}
} //end remove
template class elemType>
arrayListType
{
if (size
{
cerr
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new elemType[maxSize];
assert(list != NULL);
}
template class elemType>
arrayListType
{
delete [] list;
}
template class elemType>
arrayListType
(const arrayListType
{
maxSize = otherList.maxSize;
length = otherList.length;
list = new elemType[maxSize]; //create the array
assert(list != NULL); //terminate if unable to allocate
//memory space
for (int j = 0; j
list [j] = otherList.list[j];
} //end copy constructor
template class elemType>
const arrayListType
(const arrayListType
{
if (this != &otherList) //avoid self-assignment
{
delete [] list;
maxSize = otherList.maxSize;
length = otherList.length;
list = new elemType[maxSize]; //create the array
assert(list != NULL); //if unable to allocate memory
//space, terminate the program
for (int i = 0; i
list[i] = otherList.list[i];
}
return *this;
}
#endif
arrayListType.h contains the definition of the template class arrayListType. Download the file and modify the class arrayListType in the following way: The function removeAt of the class arrayListType removes an element from the list by shifting the elements of the list. However, if the element to be removed is at the beginning of the list and the list is fairly large, it could take a lot of computer time. Because the list elements are in no particular order, you can simply remove the element by swapping the last element of the list with the item to be removed and reducing the length of the list. Rewrite the definition of the function removeAt using this technique. Upload your new version of the class. simple class rubric Criteria Ratings Pts class rubric 10 pts Full Marks O pts No Marks 1) the program solves the problem 2) the program uses constructors, destructors appropriately 3) the program uses mutators appropriately 4) the program uses accessors appropriately 5) the program uses custom methods appropriately 10 pts Total Points: 10 1. Data is almost always private. 2. No error message in constructors. The proper way to handle errors in constructors is to throw exceptions. Since we cannot throw exceptions, we replace bad values with good ones. 3. Avoid the "this" pointer. You can avoid it by using parameter names and local variable names that are not the same as class member names. 4. Constructors and mutators should not be interactive. 1 #ifndef H_arrayListType #define H_arrayListType 2 3 4 ****************** ******************* //********************* // Author: D.S. Malik 5 6 7 // This class specifies the members to implement the basic 8 // properties of array-based lists. 9 //************************************************************ 10 11 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
