Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: What kind of sort to use?

Author: Leen Ammeraal

Date: 12:18:36 07/31/00

Go up one level in this thread


On July 31, 2000 at 13:17:20, Larry Griffiths wrote:
>I am currently using a bubble sort to sort my captures list.
>I plan to change it to a selection sort.
>Do any of you use another type of sort like quicksort to sort your lists or do
>you have any preferences?
>
>Larry :)

In my program (Queen, written in C++) I use the STL
sort algorithm, which is an implementation of quicksort. With
the moves to be sorted stored in the array elements
moves.lst[k1], ..., moves.lst[k2-1], I write:
   sort(moves.lst+k1, moves.lst+k2);
along with a less-than operator defined in my class Move
as follows:
   bool operator<(const Move &b)const
   {  return score > b.score;
   }  // to sort the moves in descending order of the scores
Each array element moves.lst[i] is of type Move.
Of course, the following lines occur in the program file:
   #include <algorithm>
   using namespace std;
Leen Ammeraal
http://home.wxs.nl/~ammeraal/



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.