I will provide a program to test your package. Compile the program with the package, and give me the output. Warning: you should probably write another program to make sure everything works. Even if your package works with the test program, if I detect a bug, you will lose points.
I expect well-commented and well-documented code. It is a given that the program will work 100% correctly.
#include "Vector.h"
template <class Etype>
class DoubleEnded
{
public:
DoubleEnded( int MaxSize = 3 );
~DoubleEnded( ) { }
void MakeEmpty( );
void Insert( const Etype & X );
void DeleteMin( Etype & X );
void DeleteMax( Etype & X );
void DeleteMin( );
void DeleteMax( );
const Etype & FindMin( ) const;
const Etype & FindMax( ) const;
bool IsEmpty( ) const;
private:
int CurrentSize;
Vector<Etype> Element; // the array
// Disable copy constructor and copy assignment
const DoubleEnded & operator=( const DoubleEnded & )
{ return *this; }
};
You must use the Vector class that is described in
Chapter 3 and available online.
You will need
Vector.h,
and
Vector.cpp.
(Note that the DoubleEnded constructor will require
an initializer list to construct the Element data member).
You must use separate compilation.
You must double the
Element vector when it becomes full.
You must do something reasonable for accesses or deletions
on an empty DoubleEnded object.
I suggest using the EXCEPTION routine
(Exception.h,
Exception.cpp)
that is
also described in the text (and is needed by Vector anyway).
Make sure to include a comment section that explains
the properties that Etype must have in order for
the DoubleEnded template to correctly instantiate.
For instance, Etype objects must be comparable
in some way.
which CCthe correct answer is
/opt/SUNWspro/bin/CC
You may develop on other systems, but then you will have to make arrangements to get templates to work correctly. Futhermore, since Exception.h is too long a filename for 8.3 formats, you may need to rename a shortened filename back to Exception.h after you download it. Also, when you upload, you may need to tinker, and you will probably need to reformat to have proper indenting. In any event, it is your responsibility to give yourself enough lead time.