[Quantproject-developers] QuantProject/b1_ADT/Optimizing/Genetic GenomeComparer.cs,1.1,1.2
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-05-17 23:02:44
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16734/b1_ADT/Optimizing/Genetic Modified Files: GenomeComparer.cs Log Message: IComparer implementation is clearer, now Index: GenomeComparer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GenomeComparer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeComparer.cs 1 Dec 2004 22:36:11 -0000 1.1 --- GenomeComparer.cs 17 May 2005 23:02:35 -0000 1.2 *************** *** 36,48 **** public int Compare( object x, object y) { ! if ( !(x is Genome) || !(y is Genome)) ! throw new ArgumentException("Not of type Genome"); ! ! if (((Genome) x).Fitness > ((Genome) y).Fitness) ! return 1; ! else if (((Genome) x).Fitness == ((Genome) y).Fitness) ! return 0; else ! return -1; } } --- 36,57 ---- public int Compare( object x, object y) { ! int returnValue = 0; ! ! if((x is Genome) && (y is Genome)) ! { ! if ( ((Genome) x).Fitness > ((Genome) y).Fitness ) ! returnValue = 1; ! else if ( ((Genome) x).Fitness < ((Genome) y).Fitness ) ! returnValue = -1; ! } else ! throw new ArgumentException("Both objects to compare must be genomes!"); ! //old implementation ! //else if ( !(x is Genome) && (y is Genome)) ! //returnValue = -1; ! //else if ((x is Genome) && !(y is Genome)) ! //returnValue = 1; ! ! return returnValue; } } |