#include #include "ArrayT.h" #include // for random numbers using namespace std; const int NUMBER_LIMIT = 1000; void ArrayInfo(ArrayT ary); void PrintArray(ArrayT ary); void FillArray(ArrayT & ary); void Swap(ArrayT & ary, size_t i, size_t j); void Sort(ArrayT & ary); void RandomizeArray(ArrayT & ary); void StickMoreIn(ArrayT & ary); int main() { ArrayT ary; srand(time(nullptr)); ArrayInfo(ary); FillArray(ary); ArrayInfo(ary); Sort(ary); ArrayInfo(ary); RandomizeArray(ary); ArrayInfo(ary); Sort(ary); ArrayInfo(ary); cout << "Growing " << endl; StickMoreIn(ary); ArrayInfo(ary); cout << "Growing more" << endl; StickMoreIn(ary); ArrayInfo(ary); cout << "Growing even more" << endl; StickMoreIn(ary); ArrayInfo(ary); return 0; } void PrintArray(ArrayT ary){ size_t i; if (ary.Size() > 0) { cout << ary.At(0); for(i =1; i < ary.Size();i++) { cout <<", " << ary.At(i); } } return; } void ArrayInfo(ArrayT ary){ cout << "Array Information" << endl; cout << "\tArray Size: " << ary.Size() << endl; cout << "\tArray Capacity: " << ary.Capacity() << endl; cout << "\tElements: "; if (ary.Size() == 0) { cout << "\tEmpty" << endl; } else { PrintArray(ary); cout << endl; } cout << endl; return; } void FillArray(ArrayT & ary){ size_t i; for(i=0;i 0) { if (rand() % 10 > 8) { cout << "\tDeleting " << ary.At(i) << endl; Swap(ary, i, ary.Size()-1); ary.Delete(); deletes ++; } else { j = rand()%ary.Size(); cout << "\tSwapping " << ary.At(i) << " and " << ary.At(j) << endl; Swap(ary, i,j); } i--; } cout << " Deleted " << deletes << " items." << endl; cout << endl; return; } void StickMoreIn(ArrayT & ary) { size_t i; size_t limit = ary.Capacity(); for(i=0;i