mirror of https://github.com/xfarrow/lasd.git
parent
46c52c6132
commit
858e7debee
|
@ -6,7 +6,7 @@
|
||||||
#include "../stack/stack.hpp"
|
#include "../stack/stack.hpp"
|
||||||
#include "../stack/lst/stacklst.hpp"
|
#include "../stack/lst/stacklst.hpp"
|
||||||
#include "../stack/vec/stackvec.hpp"
|
#include "../stack/vec/stackvec.hpp"
|
||||||
|
#include<iostream>
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
@ -21,11 +21,22 @@ bool BinaryTree<Data>::Node::operator==(const Node& toEvaluate) const noexcept{
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
bool BinaryTree<Data>::Node::EqualNodes(const Node& n1, const Node& n2) const{
|
bool BinaryTree<Data>::Node::EqualNodes(const Node& n1, const Node& n2) const{
|
||||||
if(n1.data == n2.data){
|
if(n1.data == n2.data){
|
||||||
if(n1.IsLeaf() && n2.IsLeaf()) return true;
|
|
||||||
if( (n1.HasLeftChild() && !n2.HasLeftChild()) || (n1.HasRightChild() && !n2.HasRightChild()) ) return false;
|
if( (n1.HasLeftChild() && !n2.HasLeftChild()) || (n1.HasRightChild() && !n2.HasRightChild()) ) return false;
|
||||||
return( EqualNodes(n1.LeftChild(),n2.LeftChild()) &&
|
|
||||||
EqualNodes(n1.RightChild(),n2.RightChild())
|
if(n1.HasLeftChild() && n1.HasRightChild()){
|
||||||
);
|
return( EqualNodes(n1.LeftChild(),n2.LeftChild()) && EqualNodes(n1.RightChild(),n2.RightChild()));
|
||||||
|
}
|
||||||
|
else if(n1.HasLeftChild() && !n1.HasRightChild()){
|
||||||
|
return( EqualNodes(n1.LeftChild(),n2.LeftChild()));
|
||||||
|
}
|
||||||
|
else if(!n1.HasLeftChild() && n1.HasRightChild()){
|
||||||
|
return( EqualNodes(n1.RightChild(),n2.RightChild()));
|
||||||
|
}
|
||||||
|
else if(n1.IsLeaf()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +59,7 @@ const Data& BinaryTree<Data>::Node::Element() const{
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
bool BinaryTree<Data>::operator==(const BinaryTree& toCompare) const noexcept{
|
bool BinaryTree<Data>::operator==(const BinaryTree& toCompare) const noexcept{
|
||||||
|
if(size!=toCompare.size) return false;
|
||||||
return(Root() == toCompare.Root());
|
return(Root() == toCompare.Root());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool BinaryTreeVec<Data>::NodeVec::IsLeaf() const noexcept{
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
bool BinaryTreeVec<Data>::NodeVec::HasLeftChild() const noexcept{
|
bool BinaryTreeVec<Data>::NodeVec::HasLeftChild() const noexcept{
|
||||||
if(index*2+1 < ReferenceToTree->size){
|
if( (index*2)+1 < ReferenceToTree->size){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
@ -41,7 +41,7 @@ bool BinaryTreeVec<Data>::NodeVec::HasLeftChild() const noexcept{
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
bool BinaryTreeVec<Data>::NodeVec::HasRightChild() const noexcept{
|
bool BinaryTreeVec<Data>::NodeVec::HasRightChild() const noexcept{
|
||||||
if(index*2+2 < ReferenceToTree->size){
|
if((index*2)+2 < ReferenceToTree->size){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
g++ -O3 -o main \
|
g++ -g -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/exercise3/simpletest.cpp zlasdtest/exercise3/fulltest.cpp \
|
zlasdtest/exercise3/simpletest.cpp zlasdtest/exercise3/fulltest.cpp \
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::cout << "Lasd Libraries 2020" << std::endl;
|
std::cout << "Lasd Libraries 2020" << std::endl;
|
||||||
|
//menu();
|
||||||
lasdtest(); // To call in the menu of your library test!
|
lasdtest(); // To call in the menu of your library test!
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,10 @@ 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();
|
||||||
testSimpleExercise3();
|
testSimpleExercise3();
|
||||||
testFullExercise3();
|
testFullExercise3();
|
||||||
cout << endl << "Goodbye!" << endl;
|
cout << endl << "Goodbye!" << endl;
|
||||||
|
|
|
@ -2,10 +2,27 @@
|
||||||
#ifndef MYTEST_HPP
|
#ifndef MYTEST_HPP
|
||||||
#define MYTEST_HPP
|
#define MYTEST_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include"../vector/vector.hpp"
|
||||||
|
#include"../list/list.hpp"
|
||||||
|
#include"../queue/queue.hpp"
|
||||||
|
#include"../queue/lst/queuelst.hpp"
|
||||||
|
#include"../queue/vec/queuevec.hpp"
|
||||||
|
#include"../stack/stack.hpp"
|
||||||
|
#include"../stack/lst/stacklst.hpp"
|
||||||
|
#include"../stack/vec/stackvec.hpp"
|
||||||
|
#include"../iterator/iterator.hpp"
|
||||||
|
#include"../binarytree/binarytree.hpp"
|
||||||
|
#include"../binarytree/lnk/binarytreelnk.hpp"
|
||||||
|
#include"../binarytree/vec/binarytreevec.hpp"
|
||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
// ...
|
void menu(){
|
||||||
|
std::cout<<"MYTESTS\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue