public override float CompareByValue(IStatisticElement element) { ChampionshipDataElement other = (ChampionshipDataElement)element; if (this.Points != other.Points) { return(this.Points - other.Points); } else { return(base.CompareByValue(element)); } }
public override float CompareByValue(IStatisticElement element) { FinishingPositionChampionshipElement other = (FinishingPositionChampionshipElement)element; for (int positionIndex = 0; positionIndex < Data.NumberOfDrivers; positionIndex++) { if (this.NumberOfResults[positionIndex] != other.NumberOfResults[positionIndex]) { return(this.NumberOfResults[positionIndex] - other.NumberOfResults[positionIndex]); } } return(0); }
public override float CompareByPercentage(IStatisticElement element) { SessionPointsDeltaDataElement other = (SessionPointsDeltaDataElement)element; if (this.PointsDeltaPercentage == other.PointsDeltaPercentage) { return(CompareByValue(element)); } else { return(this.PointsDeltaPercentage - other.PointsDeltaPercentage); } }
public override float CompareByPercentage(IStatisticElement element) { ChampionshipDataElement other = (ChampionshipDataElement)element; if (this.Percentage != other.Percentage) { return(this.Percentage - other.Percentage); } else { return(CompareByValue(element)); } }
public override float CompareByValue(IStatisticElement element) { AverageFinishAbovePositionDataElement other = (AverageFinishAbovePositionDataElement)element; if (this.AverageFinishAbovePosition == other.AverageFinishAbovePosition) { return(0F); } else if (this.AverageFinishAbovePosition == 0) { return(Data.NumberOfDrivers); } else if (other.AverageFinishAbovePosition == 0) { return(-Data.NumberOfDrivers); } return(this.AverageFinishAbovePosition - other.AverageFinishAbovePosition); }
public IStatisticElement[] CalculateComparisonStatistics() { IStatisticElement[] comparisonArray = new IStatisticElement[Data.NumberOfDrivers]; //An array of the position in the comparison array at which the first found driver //in the team is located. //Indexed by team index. int[] teamIndices = new int[Data.NumberOfDrivers / 2]; //Set all to -1 because no teams have been found yet. for (int driverIndex = 0; driverIndex < Data.NumberOfDrivers / 2; driverIndex++) { teamIndices[driverIndex] = -1; } int indexToInsertNextStatistic = 0; for (int driverIndex = 0; driverIndex < Data.NumberOfDrivers; driverIndex++) { if (teamIndices[Driver.GetTeamIndex(DriverStats[driverIndex].CompetitorIndex)] == -1) { //The team has not yet been seen so this is the highest position in the team. //The element can be inserted at the next available position in the array. comparisonArray[indexToInsertNextStatistic] = DriverStats[driverIndex]; //Update the team indices array to reflect where the first driver in the team was located. teamIndices[Driver.GetTeamIndex(DriverStats[driverIndex].CompetitorIndex)] = indexToInsertNextStatistic; //Update the next available position in the array. indexToInsertNextStatistic += 2; } else { //The team has already been seen so this driver goes next to his teammate. comparisonArray[teamIndices[Driver.GetTeamIndex(DriverStats[driverIndex].CompetitorIndex)] + 1] = DriverStats[driverIndex]; } } return(comparisonArray); }
/// <summary> /// <para>Compares another instance of data element with this element.</para> /// <para>Returns a larger number if this should be ordered first in an ascending list.</para> /// </summary> /// <param name="element">The statistic element to compare to this</param> /// <param name="sortType">Represents the way that the array is sorted</param> /// <param name="ascending">True if the list is ascending</param> /// <exception cref="CannotSortByThisParameterException">Throws this exception if the data element cannot be sorted by this sort type.</exception> public float CompareTo(IStatisticElement element, SortType sortType, OrderType orderType) { float returnValue = 0; switch (sortType) { case SortType.Index: returnValue = (this.CompetitorIndex - element.CompetitorIndex); break; case SortType.Percentage: returnValue = CompareByPercentage(element); break; case SortType.Value: returnValue = CompareByValue(element); break; default: throw new CannortSortByThisParameterException(sortType); } return((orderType == OrderType.Ascending ? 1 : -1) * returnValue); }
public override float CompareByValue(IStatisticElement element) { SessionPointsDeltaDataElement other = (SessionPointsDeltaDataElement)element; return((float)(this.AveragePointsDelta - other.AveragePointsDelta)); }
float IStatisticElement.CompareTo(IStatisticElement element, SortType sortType, OrderType orderType) { return(CompareTo(element, sortType, orderType)); }
public virtual float CompareByValue(IStatisticElement element) { throw new CannortSortByThisParameterException(SortType.Value); }
public override float CompareByPercentage(IStatisticElement element) { return(base.CompareByPercentage(element)); }
public override float CompareByPercentage(IStatisticElement element) { TeammateComparisonDataElement other = (TeammateComparisonDataElement)element; return(this.PercentageFinishesAhead - other.PercentageFinishesAhead); }
public override float CompareByValue(IStatisticElement element) { TeammateComparisonDataElement other = (TeammateComparisonDataElement)element; return(this.finishesAheadOfTeammate - other.finishesAheadOfTeammate); }