pub fn is_score_better<P: PerThing>(this: ElectionScore, that: ElectionScore, epsilon: P) -> bool
	where ExtendedBalance: From<sp_arithmetic::InnerOf<P>>
{
	match this
		.iter()
		.enumerate()
		.map(|(i, e)| (
			e.ge(&that[i]),
			e.tcmp(&that[i], epsilon.mul_ceil(that[i])),
		))
		.collect::<Vec<(bool, Ordering)>>()
		.as_slice()
	{
		// epsilon better in the score[0], accept.
		[(_, Ordering::Greater), _, _] => true,

		// less than epsilon better in score[0], but more than epsilon better in the second.
		[(true, Ordering::Equal), (_, Ordering::Greater), _] => true,

		// less than epsilon better in score[0, 1], but more than epsilon better in the third
		[(true, Ordering::Equal), (true, Ordering::Equal), (_, Ordering::Less)] => true,

		// anything else is not a good score.
		_ => false,
	}
}
/// Compares two sets of election scores based on desirability and returns true if `this` is better
/// than `that`.
///
/// Evaluation is done in a lexicographic manner, and if each element of `this` is `that * epsilon`
/// greater or less than `that`.
///
/// Note that the third component should be minimized.
Compares two sets of election scores based on desirability and returns true if `this` is better
than `that`.



Note that the third component should be minimized.
Compares two sets of election scores based on desirability and returns true if ` this ` is better than ` that ` . Note that the third component should be minimized .
pub fn is_score_better<P: PerThing>(this: ElectionScore, that: ElectionScore, epsilon: P) -> bool
	where ExtendedBalance: From<sp_arithmetic::InnerOf<P>>
{
	match this
		.iter()
		.enumerate()
		.map(|(i, e)| (
			e.ge(&that[i]),
			e.tcmp(&that[i], epsilon.mul_ceil(that[i])),
		))
		.collect::<Vec<(bool, Ordering)>>()
		.as_slice()
	{
		// epsilon better in the score[0], accept.
		[(_, Ordering::Greater), _, _] => true,
		// less than epsilon better in score[0], but more than epsilon better in the second.
		[(true, Ordering::Equal), (_, Ordering::Greater), _] => true,
		// less than epsilon better in score[0, 1], but more than epsilon better in the third
		[(true, Ordering::Equal), (true, Ordering::Equal), (_, Ordering::Less)] => true,
		// anything else is not a good score.
		_ => false,
	}
}
pub fn is_score_better < P : PerThing > ( this : ElectionScore , that : ElectionScore , epsilon : P ) -> bool where ExtendedBalance : From < sp_arithmetic :: InnerOf < P > > { match this . iter ( ) . enumerate ( ) . map ( | ( i , e ) | ( e . ge ( & that [ i ] ) , e . tcmp ( & that [ i ] , epsilon . mul_ceil ( that [ i ] ) ) , ) ) . collect :: < Vec < ( bool , Ordering ) > > ( ) . as_slice ( ) { // epsilon better in the score[0], accept. [ ( _ , Ordering :: Greater ) , _ , _ ] => true , // less than epsilon better in score[0], but more than epsilon better in the second. [ ( true , Ordering :: Equal ) , ( _ , Ordering :: Greater ) , _ ] => true , // less than epsilon better in score[0, 1], but more than epsilon better in the third [ ( true , Ordering :: Equal ) , ( true , Ordering :: Equal ) , ( _ , Ordering :: Less ) ] => true , // anything else is not a good score. _ => false , } }
Compares two sets of election scores based on desirability and returns true if `this` is better
than `that`.
Compares two sets of election scores based on desirability and returns true if ` this ` is better than ` that ` .
this
ElectionScore
that
ElectionScore
epsilon
P
this
ElectionScore
that
ElectionScore
epsilon
P