Created
May 22, 2012 20:05
-
-
Save anonymous/2771303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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] << " "; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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