Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2012 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2771303 to your computer and use it in GitHub Desktop.
Save anonymous/2771303 to your computer and use it in GitHub Desktop.
//SortData.cpp
#include <cstdlib>
#include <iostream>
#include "SortData.h"
using namespace std;
SortData::SortData(int max)
{
maxSize = max;
theData = new long[max];
randomize(12);
}
void SortData::randomize(int seed)
{
srand(seed);
for(int i = 0; i<maxSize; ++i)
theData[i] = rand() * rand();
}
SortData::~SortData(void)
{
delete [] theData;
theData = 0; //Set equal to zero
maxSize = 0;
}
int SortData::size() const
{
int arraySize = 0;
while(arraySize < maxSize && theData[arraySize] != NULL)
{
arraySize++;
}
return arraySize;
}
void SortData::printSome(const int num) const
{
int number = num;
if(number > maxSize) number = maxSize;
for(int i = 0; i<number; i++)
cout << theData[i] << " ";
}
//Sortdata.h
class SortData
{
public:
SortData(int max=100);
~SortData(void);
int size() const;
void randomize(int seed = 1);
void printSome(const int num=10) const;
virtual _int64 sort() = 0;
protected:
long *theData;
int maxSize;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment