Beispiel #1
0
 int partition(int first, int last)
 {
     // move elements satisfying _Pred to beginning of sequence
     for (; ; ++first)
     {   // find any out-of-order pair
         for (; first != last && (ms[first].score > 0); ++first)
         {
             ;   // skip in-place elements at beginning
         }
         if (first == last)
         {
             break;      // done
         }
         for (; first != --last && (ms[last].score <= 0);)
         {
             ;   // skip in-place elements at end
         }
         if (first == last)
         {
             break;      // done
         }
         MoveStack temp = ms[last]; ms[last] = ms[first]; ms[first] = temp;
     }
     return(first);
 }
Beispiel #2
0
        int pick_best()
        {
            int first = curMovePos;
            int max   = curMovePos;

            if (first != lastMovePos)
            {
                for (; ++first != lastMovePos;)
                {
                    if (ms[max].score < ms[first].score)
                    {
                        max = first;
                    }
                }
            }
            MoveStack temp = ms[curMovePos]; ms[curMovePos] = ms[max]; ms[max] = temp;

            return(curMovePos);
        }