From 4c4d35716f9677be8af70a8040bd53bca4833314 Mon Sep 17 00:00:00 2001 From: obiwankennedy Date: Wed, 8 Jan 2014 18:14:27 +0100 Subject: Update sortresult.cpp manual sort because of die*. --- node/sortresult.cpp | 54 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'node') diff --git a/node/sortresult.cpp b/node/sortresult.cpp index 0291d14..9797310 100644 --- a/node/sortresult.cpp +++ b/node/sortresult.cpp @@ -19,18 +19,53 @@ void SortResultNode::run(ExecutionNode* node) DiceResult* previousDiceResult = static_cast(node->getResult()); if(NULL!=previousDiceResult) { - QList diceList=previousDiceResult->getResultList(); - QList diceList2=m_diceResult->getResultList(); + QList diceList=previousDiceResult->getResultList(); + QList diceList2=m_diceResult->getResultList(); + + /*diceList2 = diceList; - diceList2 = diceList; if(!m_ascending) { - qSort(diceList2.begin(), diceList2.end(), qGreater()); + qSort(diceList2.begin(), diceList2.end(), qGreater()); } else { - qSort(diceList2.begin(), diceList2.end(), qLess()); + qSort(diceList2.begin(), diceList2.end(), qLess()); + }*/ + + + for(int i = 0; igetValue() << tmp2->getValue() << j; + if(tmp1->getValue() < tmp2->getValue()) + { + found = true; + } + } + if(found) + diceList2.insert(j-1,tmp1); + else + diceList2.append(tmp1); + } + + if(!m_ascending) + { + for(int i = 0; i< diceList2.size()/2; ++i) + { + diceList2.swap(i,diceList2.size()-(1+i)); + } + + } + + + m_diceResult->setResultList(diceList2); if(NULL!=m_nextNode) { @@ -43,12 +78,3 @@ void SortResultNode::setSortAscending(bool asc) { m_ascending = asc; } - - -bool operator<(Die const &a, Die const& b) -{ - if(a.getValue()