mirror of https://github.com/xfarrow/lasd.git
parent
0a8d458eb1
commit
bc95674b37
Binary file not shown.
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::cout << "Lasd Libraries 2020" << std::endl;
|
std::cout << "Lasd Libraries 2020" << std::endl;
|
||||||
lasdtest();
|
|
||||||
menu();
|
menu();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,13 @@
|
||||||
|
|
||||||
using namespace lasd;
|
using namespace lasd;
|
||||||
|
|
||||||
|
|
||||||
void menu(){
|
void menu(){
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void menu(){
|
|
||||||
|
|
||||||
|
|
||||||
unsigned short int choice;
|
unsigned short int choice;
|
||||||
DataStructure chosenDataStructure;
|
DataStructure chosenDataStructure;
|
||||||
DataType chosenDataType;
|
DataType chosenDataType;
|
||||||
Implementation chosenImplementation;
|
Implementation chosenImplementation;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
std::cout<<"1. Use your tests (to be used by the professor)"<<std::endl;
|
std::cout<<"1. Use your tests (to be used by the professor)"<<std::endl;
|
||||||
std::cout<<"2. Use the library demo"<<std::endl;
|
std::cout<<"2. Use the library demo"<<std::endl;
|
||||||
|
@ -28,15 +24,13 @@ void menu(){
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
chosenDataStructure = ChooseDataStructure();
|
chosenDataStructure = ChooseDataStructure();
|
||||||
chosenDataType = ChooseDataType();
|
|
||||||
chosenImplementation = ChooseImplementation();
|
chosenImplementation = ChooseImplementation();
|
||||||
UseChosenType(chosenDataStructure,chosenDataType, chosenImplementation);
|
chosenDataType = ChooseDataType();
|
||||||
|
UseChosenType(chosenDataStructure, chosenDataType, chosenImplementation);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
std::cout<<"An error has occurred"<<std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataStructure ChooseDataStructure(){
|
DataStructure ChooseDataStructure(){
|
||||||
unsigned short int choice;
|
unsigned short int choice;
|
||||||
do{
|
do{
|
||||||
|
@ -51,6 +45,7 @@ DataStructure ChooseDataStructure(){
|
||||||
else if(choice == 2)
|
else if(choice == 2)
|
||||||
return DataStructure::queue;
|
return DataStructure::queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataType ChooseDataType(){
|
DataType ChooseDataType(){
|
||||||
unsigned short int choice;
|
unsigned short int choice;
|
||||||
do{
|
do{
|
||||||
|
@ -68,6 +63,7 @@ DataType ChooseDataType(){
|
||||||
else if(choice==3)
|
else if(choice==3)
|
||||||
return DataType::sstring;
|
return DataType::sstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
Implementation ChooseImplementation(){
|
Implementation ChooseImplementation(){
|
||||||
unsigned short int choice;
|
unsigned short int choice;
|
||||||
do{
|
do{
|
||||||
|
@ -76,7 +72,7 @@ Implementation ChooseImplementation(){
|
||||||
std::cout<<"2. List"<<std::endl;
|
std::cout<<"2. List"<<std::endl;
|
||||||
std::cin>>std::ws;
|
std::cin>>std::ws;
|
||||||
std::cin>>choice;
|
std::cin>>choice;
|
||||||
}while(!(choice>0 && choice<4));
|
}while(!(choice>0 && choice<3));
|
||||||
if(choice==1)
|
if(choice==1)
|
||||||
return Implementation::vector;
|
return Implementation::vector;
|
||||||
else if(choice==2)
|
else if(choice==2)
|
||||||
|
@ -87,20 +83,252 @@ void UseChosenType(DataStructure chosenDataStructure, DataType chosenDataType, I
|
||||||
if(chosenDataStructure == DataStructure::stack){
|
if(chosenDataStructure == DataStructure::stack){
|
||||||
if(chosenImplementation == Implementation::vector){
|
if(chosenImplementation == Implementation::vector){
|
||||||
if(chosenDataType == DataType::integer){
|
if(chosenDataType == DataType::integer){
|
||||||
lasd::StackVec<int> myvec;
|
StackVec<int> stckvec;
|
||||||
myvec = generateVectorOfIntegers();
|
stckvec = generateRandomStackVecInt();
|
||||||
VectorIntegerFunctions(myvec);
|
}
|
||||||
}else if(chosenDataType == DataType::ffloat){
|
else if(chosenDataType == DataType::ffloat){
|
||||||
lasd::StackVec<float> myvec;
|
StackVec<float> stckvec;
|
||||||
myvec = generateVectorOfFloat();
|
stckvec = generateRandomStackVecFloat();
|
||||||
VectorFloatFunctions(myvec);
|
}
|
||||||
}else if(chosenDataType == DataType::sstring){
|
else if(chosenDataType == DataType::sstring){
|
||||||
lasd::StackVec<std::string> myvec;
|
StackVec<std::string> stckvec;
|
||||||
myvec = generateVectorOfStrings();
|
stckvec = generateRandomStackVecString();
|
||||||
VectorStringFunctions(myvec);
|
}
|
||||||
|
}
|
||||||
|
else if(chosenImplementation == Implementation::list){
|
||||||
|
if(chosenDataType == DataType::integer){
|
||||||
|
StackLst<int> stcklst;
|
||||||
|
stcklst = generateRandomStackLstInt();
|
||||||
|
}
|
||||||
|
else if(chosenDataType == DataType::ffloat){
|
||||||
|
StackLst<float> stcklst;
|
||||||
|
stcklst = generateRandomStackLstFloat();
|
||||||
|
}
|
||||||
|
else if(chosenDataType == DataType::sstring){
|
||||||
|
StackLst<std::string> stcklst;
|
||||||
|
stcklst = generateRandomStackLstString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(chosenDataStructure == DataStructure::queue){
|
||||||
|
if(chosenImplementation == Implementation::vector){
|
||||||
|
if(chosenDataType == DataType::integer){
|
||||||
|
QueueVec<int> queuevec;
|
||||||
|
queuevec = generateRandomQueueVecInt();
|
||||||
|
}
|
||||||
|
else if(chosenDataType == DataType::ffloat){
|
||||||
|
QueueVec<float> queuevec;
|
||||||
|
queuevec = generateRandomQueueVecFloat();
|
||||||
|
}
|
||||||
|
else if(chosenDataType == DataType::sstring){
|
||||||
|
QueueVec<std::string> queuevec;
|
||||||
|
queuevec = generateRandomQueueVecString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(chosenImplementation == Implementation::list){
|
||||||
|
if(chosenDataType == DataType::integer){
|
||||||
|
QueueLst<int> queuelist;
|
||||||
|
queuelist = generateRandomQueueListInt();
|
||||||
|
}
|
||||||
|
else if(chosenDataType == DataType::ffloat){
|
||||||
|
QueueLst<float> queuelist;
|
||||||
|
queuelist = generateRandomQueueListFloat();
|
||||||
|
}
|
||||||
|
else if(chosenDataType == DataType::sstring){
|
||||||
|
QueueLst<std::string> queuelist;
|
||||||
|
queuelist = generateRandomQueueListString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
lasd::QueueLst<int> generateRandomQueueListInt(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
int tmp;
|
||||||
|
QueueLst<int> myqueue;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(0,1000);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the Queue list:"<<std::endl;
|
||||||
|
for(ulong i = 0 ; i<dim ; ++i){
|
||||||
|
tmp = dist(gen);
|
||||||
|
myqueue.Enqueue(tmp);
|
||||||
|
std::cout<<tmp<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myqueue;
|
||||||
|
}
|
||||||
|
lasd::QueueLst<float> generateRandomQueueListFloat(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
float tmp;
|
||||||
|
QueueLst<float> myqueue;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_real_distribution<float> distr(0,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the Queue list:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
tmp = (round(distr(gen)*10000))/100;
|
||||||
|
myqueue.Enqueue(tmp);
|
||||||
|
std::cout<<tmp<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myqueue;
|
||||||
|
}
|
||||||
|
lasd::QueueLst<std::string> generateRandomQueueListString(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
std::string tmp;
|
||||||
|
QueueLst<std::string> myqueue;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(1,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the Queue list:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
tmp = generateRandomString(dist(gen));
|
||||||
|
myqueue.Enqueue(tmp);
|
||||||
|
std::cout<<tmp<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myqueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lasd::QueueVec<int> generateRandomQueueVecInt(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
int tmp;
|
||||||
|
QueueVec<int> myqueue;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(0,1000);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the Queue vector:"<<std::endl;
|
||||||
|
for(ulong i = 0 ; i<dim ; ++i){
|
||||||
|
tmp = dist(gen);
|
||||||
|
myqueue.Enqueue(tmp);
|
||||||
|
std::cout<<tmp<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myqueue;
|
||||||
|
}
|
||||||
|
lasd::QueueVec<float> generateRandomQueueVecFloat(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
float tmp;
|
||||||
|
QueueVec<float> myqueue;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_real_distribution<float> distr(0,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the Queue vector:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
tmp = (round(distr(gen)*10000))/100;
|
||||||
|
myqueue.Enqueue(tmp);
|
||||||
|
std::cout<<tmp<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myqueue;
|
||||||
|
}
|
||||||
|
lasd::QueueVec<std::string> generateRandomQueueVecString(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
std::string tmp;
|
||||||
|
QueueVec<std::string> myqueue;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(1,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the Queue vector:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
tmp = generateRandomString(dist(gen));
|
||||||
|
myqueue.Enqueue(tmp);
|
||||||
|
std::cout<<tmp<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myqueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lasd::StackLst<int> generateRandomStackLstInt(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
StackLst<int> myvec;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(0,1000);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the vector:"<<std::endl;
|
||||||
|
for(ulong i = 0 ; i<dim ; ++i){
|
||||||
|
myvec.Push(dist(gen));
|
||||||
|
std::cout<<myvec.Top()<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myvec;
|
||||||
|
}
|
||||||
|
lasd::StackLst<float> generateRandomStackLstFloat(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
StackLst<float> myvec;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_real_distribution<float> distr(0,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the vector:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
myvec.Push( float((round(distr(gen)*10000))/100) );
|
||||||
|
std::cout<<myvec.Top()<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myvec;
|
||||||
|
}
|
||||||
|
lasd::StackLst<std::string> generateRandomStackLstString(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
StackLst<std::string> myvec;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(1,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the vector:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
myvec.Push( generateRandomString(dist(gen)) );
|
||||||
|
std::cout<<myvec.Top()<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myvec;
|
||||||
|
}
|
||||||
|
|
||||||
|
lasd::StackVec<int> generateRandomStackVecInt(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
StackVec<int> myvec;
|
||||||
|
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(0,1000);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the vector:"<<std::endl;
|
||||||
|
for(ulong i = 0 ; i<dim ; ++i){
|
||||||
|
myvec.Push(dist(gen));
|
||||||
|
std::cout<<myvec.Top()<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myvec;
|
||||||
|
}
|
||||||
|
lasd::StackVec<float> generateRandomStackVecFloat(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
StackVec<float> myvec;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_real_distribution<float> distr(0,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the vector:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
myvec.Push( (round(distr(gen)*10000))/100 );
|
||||||
|
std::cout<<myvec.Top()<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myvec;
|
||||||
|
}
|
||||||
|
lasd::StackVec<std::string> generateRandomStackVecString(){
|
||||||
|
ulong dim = getDimension();
|
||||||
|
StackVec<std::string> myvec;
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(1,5);
|
||||||
|
std::cout<<std::endl<<std::endl<<"Elements of the vector:"<<std::endl;
|
||||||
|
for(unsigned long i = 0; i < dim; ++i){
|
||||||
|
myvec.Push(generateRandomString(dist(gen)));
|
||||||
|
std::cout<<myvec.Top()<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl<<std::endl;
|
||||||
|
return myvec;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string generateRandomString(ulong dim){
|
||||||
|
std::default_random_engine gen(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<char> character('a','z');
|
||||||
|
char newString[dim+1];
|
||||||
|
for(int i=0;i<dim;i++){
|
||||||
|
newString[i]=character(gen);
|
||||||
|
}
|
||||||
|
newString[dim]='\0';
|
||||||
|
return newString;
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong getDimension(){
|
||||||
|
ulong dimension;
|
||||||
|
std::cout<<"Insert the dimension: ";
|
||||||
|
std::cin>>dimension;
|
||||||
|
return dimension;
|
||||||
|
}
|
||||||
|
|
|
@ -14,10 +14,29 @@
|
||||||
enum class DataStructure{stack,queue};
|
enum class DataStructure{stack,queue};
|
||||||
enum class DataType{integer,ffloat,sstring};
|
enum class DataType{integer,ffloat,sstring};
|
||||||
enum class Implementation{vector,list};
|
enum class Implementation{vector,list};
|
||||||
|
|
||||||
void menu();
|
void menu();
|
||||||
|
|
||||||
DataType ChooseDataType(); //choose data type
|
DataType ChooseDataType(); //choose data type
|
||||||
DataStructure ChooseDataStructure();
|
DataStructure ChooseDataStructure();
|
||||||
void UseChosenType(DataStructure, DataType);
|
Implementation ChooseImplementation();
|
||||||
|
void UseChosenType(DataStructure, DataType, Implementation);
|
||||||
|
|
||||||
|
lasd::QueueLst<int> generateRandomQueueListInt();
|
||||||
|
lasd::QueueLst<float> generateRandomQueueListFloat();
|
||||||
|
lasd::QueueLst<std::string> generateRandomQueueListString();
|
||||||
|
lasd::QueueVec<int> generateRandomQueueVecInt();
|
||||||
|
lasd::QueueVec<float> generateRandomQueueVecFloat();
|
||||||
|
lasd::QueueVec<std::string> generateRandomQueueVecString();
|
||||||
|
lasd::StackLst<int> generateRandomStackLstInt();
|
||||||
|
lasd::StackLst<float> generateRandomStackLstFloat();
|
||||||
|
lasd::StackLst<std::string> generateRandomStackLstString();
|
||||||
|
lasd::StackVec<int> generateRandomStackVecInt();
|
||||||
|
lasd::StackVec<float> generateRandomStackVecFloat();
|
||||||
|
lasd::StackVec<std::string> generateRandomStackVecString();
|
||||||
|
|
||||||
|
std::string generateRandomString(ulong);
|
||||||
|
ulong getDimension();
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
#include"test.cpp"
|
#include"test.cpp"
|
||||||
|
|
Loading…
Reference in New Issue