From 2eaaedebc6750d5984190fd0f87caf771b248ae0 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 15 Dec 2018 02:15:27 +0100 Subject: WIP --- node/parenthesesnode.cpp | 18 ++++++++++++++---- node/sortresult.cpp | 23 ++++++++++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) (limited to 'node') diff --git a/node/parenthesesnode.cpp b/node/parenthesesnode.cpp index 5e2d0e0..9e6bcec 100644 --- a/node/parenthesesnode.cpp +++ b/node/parenthesesnode.cpp @@ -30,18 +30,28 @@ void ParenthesesNode::setInternelNode(ExecutionNode* node) { m_internalNode = node; } -void ParenthesesNode::run(ExecutionNode* /*previous*/) +void ParenthesesNode::run(ExecutionNode* previous) { - //m_previousNode = previous; + m_previousNode = previous; if(nullptr!=m_internalNode) { - m_internalNode->run(this); - ExecutionNode* temp=m_internalNode; + m_internalNode->run(this); + ExecutionNode* temp=m_internalNode; while(nullptr!=temp->getNextNode()) { temp=temp->getNextNode(); } m_result = temp->getResult(); + //m_result->setPrevious(internalResult); + if(nullptr!=previous) + { + auto previousResult = previous->getResult(); + if(nullptr!=m_internalNode->getResult()) + { + m_internalNode->getResult()->setPrevious(previousResult); + } + } + //m_result = temp->getResult(); } if(nullptr!=m_nextNode) diff --git a/node/sortresult.cpp b/node/sortresult.cpp index 5406eb6..76f517e 100644 --- a/node/sortresult.cpp +++ b/node/sortresult.cpp @@ -42,15 +42,32 @@ void SortResultNode::run(ExecutionNode* node) m_diceResult->setPrevious(previousDiceResult); if(nullptr!=previousDiceResult) { - QList diceList=previousDiceResult->getResultList(); + auto const& diceList=previousDiceResult->getResultList(); QList diceList2=m_diceResult->getResultList(); + /* const auto& asce = [](const Die* a,const Die* b){ + return a->getValue() < b->getValue(); + }; + const auto& desc = [](const Die* a,const Die* b){ + return a->getValue() > b->getValue(); + }; + + for(auto const dice : diceList) + { + Die* tmp1 = new Die(*dice); + diceList2.append(tmp1); + } + if(m_ascending) + std::sort(diceList2.begin(), diceList2.end(), asce); + else + std::sort(diceList2.begin(), diceList2.end(), desc);*/ + // half-interval search sorting for(int i = 0; idisplayed(); int j =0; -- cgit v1.2.3-70-g09d2