diff options
| -rw-r--r-- | cli/displaytoolbox.cpp | 6 | ||||
| -rw-r--r-- | node/parenthesesnode.cpp | 18 | ||||
| -rw-r--r-- | node/sortresult.cpp | 23 | ||||
| -rw-r--r-- | result/result.cpp | 4 |
4 files changed, 39 insertions, 12 deletions
diff --git a/cli/displaytoolbox.cpp b/cli/displaytoolbox.cpp index 5f45e09..2edc17f 100644 --- a/cli/displaytoolbox.cpp +++ b/cli/displaytoolbox.cpp @@ -306,8 +306,8 @@ QJsonArray DisplayToolBox::diceToJson(QList<ExportedDiceResult>& diceList,bool& it = alreadyDoneColor.end(); --it; } - int i = std::distance(alreadyDoneColor.begin(), it); - sameColorDice[i].push_back(dice); + auto i = std::distance(alreadyDoneColor.begin(), it); + sameColorDice[static_cast<std::size_t>(i)].push_back(dice); } int i = 0; if(alreadyDoneColor.size()>1) @@ -316,7 +316,7 @@ QJsonArray DisplayToolBox::diceToJson(QList<ExportedDiceResult>& diceList,bool& } for(auto it = alreadyDoneColor.begin() ; it != alreadyDoneColor.end(); ++it) { - auto list = sameColorDice[i]; + auto list = sameColorDice[static_cast<std::size_t>(i)]; QJsonObject object; object["color"]=*it; object["face"]=face; 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<Die*> diceList=previousDiceResult->getResultList(); + auto const& diceList=previousDiceResult->getResultList(); QList<Die*> 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; i<diceList.size();++i) { - Die* tmp1 = new Die(); - *tmp1=*diceList[i]; + Die* tmp1 = new Die(*diceList[i]); + //*tmp1=*diceList[i]; diceList[i]->displayed(); int j =0; diff --git a/result/result.cpp b/result/result.cpp index 4378350..feede47 100644 --- a/result/result.cpp +++ b/result/result.cpp @@ -62,8 +62,8 @@ void Result::generateDotTree(QString& s) { s.append(toString(false)); s.append(" -> "); - s.append(m_previous->toString(true)); - s.append("\n"); + s.append(m_previous->toString(false)); + s.append("[label=\"previousResult\"]\n"); m_previous->generateDotTree(s); } else |