You are to make a class RangeSet that maintains a set of integers. The storage and display of the set should be in terms of ranges- a range is a group of consecutive integers that cannot be enlarged.
Input Ranges may be given in any order. Id there is only one number in a range, only one number should be displayed.
Example: given 3, 5, 1, 17..19, 4 the output would be 1, 3..5, 17..19.
The class must be able to handle an arbitrary number of input ranges and there is no constraint on the ranges the user can enter.
Your class must store the range set as a linked list of the struct RNode.
struct RNode {
int start, end;
RNode* next;
}
Each Rnode represents a range of integers. The linked list MUST be stored in increasing order and in minimal form; that is, no two nodes' ranges overlap. So, no matter what sequence of operations gives rise to it, the set {1,3,4,5,17,18,19}must be stored as 3 nodes representing ranges 1..1, 3..5 and 17..19 in that order.
Your class must be stored in files RangeSet.h and RangeSet.cpp.
INSTRUCTIONS
Produce a class that maintains a set of integers, with functions to update and display the set in terms of ranges. it should have the following functions:
void addRange(int rangeStart, int rangeEnd);
//adds all integers from RANGESTART to RANGEEND inclusive to the set
static RangeSet *Union(const RangeSet &alpha, const RangeSet &beta);
//creates a pointer to new RangeSet that is the union of two supplied RangeSets
bool isInSet(int element) const;
//returns whether the value ELEMENT is in the set or not
void deleteRange(int rangeStart, int rangeEnd);
//delete all integers from RANGESTART to RANGEEND inclusive
void deleteAllElements();
//makes the set empty
void dum() const
//prints out the set in a series of ranges
as well as a default constructor, a destructor, and an equality tester(==).
You may NOT use any data structure from the C++ Standard Template Library or other such Data Structures package.
You should write a test program called [login to view URL] that vigorously tests your class.
Make sure it complies in g++ on UNIX
Due 6/4/14 Noon
Hello,
I will create this C++ class to store a set of integers as a collection of ranges.
I will open a PMB to introduce my ploan for this project.
A IDLER