mirror of https://github.com/xfarrow/lasd.git
parent
e6cb9848ff
commit
31570d2ad4
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
g++ -g -O3 -o main \
|
g++ -O3 -o main \
|
||||||
zlasdtest/exercise1/simpletest.cpp zlasdtest/exercise1/fulltest.cpp \
|
zlasdtest/exercise1/simpletest.cpp zlasdtest/exercise1/fulltest.cpp \
|
||||||
zlasdtest/exercise2/simpletest.cpp zlasdtest/exercise2/fulltest.cpp \
|
zlasdtest/exercise2/simpletest.cpp zlasdtest/exercise2/fulltest.cpp \
|
||||||
zlasdtest/container/container.cpp \
|
zlasdtest/container/container.cpp \
|
||||||
|
|
|
@ -123,7 +123,6 @@ bool List<Data>::operator!=(const List<Data>& list) const noexcept{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void List<Data>::InsertAtFront(Data&& data){
|
void List<Data>::InsertAtFront(Data&& data){
|
||||||
struct Node* tmp = new Node(data);
|
struct Node* tmp = new Node(data);
|
||||||
|
|
Binary file not shown.
|
@ -104,6 +104,7 @@ void StackVec<Data>::Pop(){
|
||||||
Reduce();
|
Reduce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
Data StackVec<Data>::TopNPop(){
|
Data StackVec<Data>::TopNPop(){
|
||||||
Data data = Top();
|
Data data = Top();
|
||||||
|
|
|
@ -13,7 +13,7 @@ using namespace std;
|
||||||
|
|
||||||
void lasdtest() {
|
void lasdtest() {
|
||||||
cout << endl << "~*~#~*~ Welcome to the LASD Test Suite ~*~#~*~ " << endl;
|
cout << endl << "~*~#~*~ Welcome to the LASD Test Suite ~*~#~*~ " << endl;
|
||||||
//testSimpleExercise1();
|
testSimpleExercise1();
|
||||||
testFullExercise1();
|
testFullExercise1();
|
||||||
testSimpleExercise2();
|
testSimpleExercise2();
|
||||||
testFullExercise2();
|
testFullExercise2();
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
using namespace lasd;
|
using namespace lasd;
|
||||||
|
|
||||||
|
|
||||||
void menu(){
|
void menu(){
|
||||||
unsigned short int choice;
|
unsigned short int choice;
|
||||||
DataStructure chosenDataStructure;
|
DataStructure chosenDataStructure;
|
||||||
|
@ -31,6 +30,7 @@ void menu(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Chooser functions
|
||||||
DataStructure ChooseDataStructure(){
|
DataStructure ChooseDataStructure(){
|
||||||
unsigned short int choice;
|
unsigned short int choice;
|
||||||
do{
|
do{
|
||||||
|
@ -45,7 +45,6 @@ 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{
|
||||||
|
@ -63,7 +62,6 @@ 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{
|
||||||
|
@ -248,6 +246,7 @@ void QueueFunctions(T& queue){
|
||||||
}while(choice!=9 && choice!=8);
|
}while(choice!=9 && choice!=8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----- Queue functions ----- */
|
||||||
template <template <typename...> class C, typename T>
|
template <template <typename...> class C, typename T>
|
||||||
void Enqueue(C<T>& queue){
|
void Enqueue(C<T>& queue){
|
||||||
T element;
|
T element;
|
||||||
|
@ -259,19 +258,33 @@ void Enqueue(C<T>& queue){
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Dequeue(T& queue){
|
void Dequeue(T& queue){
|
||||||
queue.Dequeue();
|
try{
|
||||||
|
queue.Dequeue();
|
||||||
|
}catch(std::length_error exc){
|
||||||
|
std::cout<<"Caught length_error exception!"<<std::endl<<" what(): "<<exc.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void HeadNDequeue(T& queue){
|
void HeadNDequeue(T& queue){
|
||||||
std::cout<<"The head and dequeued element is "<<queue.HeadNDequeue();
|
try{
|
||||||
|
std::cout<<"The head and dequeued element is "<<queue.HeadNDequeue();
|
||||||
|
}catch(std::length_error exc){
|
||||||
|
std::cout<<"Caught length_error exception!"<<std::endl<<" what(): "<<exc.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Head(T& queue){
|
void Head(T& queue){
|
||||||
std::cout<<"The head is "<<queue.Head();
|
try{
|
||||||
|
std::cout<<"The head is "<<queue.Head();
|
||||||
|
}catch(std::length_error exc){
|
||||||
|
std::cout<<"Caught length_error exception!"<<std::endl<<" what(): "<<exc.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- Stack functions ----- */
|
||||||
template <template <typename...> class C, typename T>
|
template <template <typename...> class C, typename T>
|
||||||
void Push(C<T>& stk){
|
void Push(C<T>& stk){
|
||||||
T element;
|
T element;
|
||||||
|
@ -283,38 +296,51 @@ void Push(C<T>& stk){
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Pop(T& stk){
|
void Pop(T& stk){
|
||||||
stk.Pop();
|
try{
|
||||||
|
stk.Pop();
|
||||||
|
}catch(std::length_error exc){
|
||||||
|
std::cout<<"Caught length_error exception!"<<std::endl<<" what(): "<<exc.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void TopNPop(T& stk){
|
void TopNPop(T& stk){
|
||||||
std::cout<<"Element top & popped is: "<<stk.TopNPop();
|
try{
|
||||||
|
std::cout<<"Element top & popped is: "<<stk.TopNPop();
|
||||||
|
}catch(std::length_error exc){
|
||||||
|
std::cout<<"Caught length_error exception!"<<std::endl<<" what(): "<<exc.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Top(T& stk){
|
void Top(T& stk){
|
||||||
std::cout<<"Element on top is: "<<stk.Top();
|
try{
|
||||||
|
std::cout<<"The element on top is: "<<stk.Top();
|
||||||
|
}catch(std::length_error exc){
|
||||||
|
std::cout<<"Caught length_error exception!"<<std::endl<<" what(): "<<exc.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----- Shared functions ----- */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Empty(T& stk){
|
void Empty(T& str){
|
||||||
std::cout<<"It is ";
|
std::cout<<"It is ";
|
||||||
stk.Empty()? std::cout<<"" : std::cout<<"not ";
|
str.Empty()? std::cout<<"" : std::cout<<"not ";
|
||||||
std::cout<<"empty";
|
std::cout<<"empty";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Size(T& stk){
|
void Size(T& str){
|
||||||
std::cout<<"Size is "<<stk.Size();
|
std::cout<<"Size is "<<str.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Clear(T& stk){
|
void Clear(T& str){
|
||||||
stk.Clear();
|
str.Clear();
|
||||||
std::cout<<"It has been cleared.";
|
std::cout<<"It has been cleared.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----- Generator functions ----- */
|
||||||
lasd::QueueLst<int> generateRandomQueueListInt(){
|
lasd::QueueLst<int> generateRandomQueueListInt(){
|
||||||
ulong dim = getDimension();
|
ulong dim = getDimension();
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
Loading…
Reference in New Issue