Assumption -- The Vec<f32> does not have any NaN values or exhibit any NaN behavior.
Take the following sample set:
0.28
0.3102
0.9856
0.3679
0.3697
0.46
0.4311
0.9781
0.9891
0.5052
0.9173
0.932
0.8365
0.5822
0.9981
0.9977
What is the neatest and most stable way to get the index of the highest value in the above list (values can be negative)?
My initial attempts were along the following lines:
let _tmp = *nets.iter().max_by(|i, j| i.partial_cmp(j).unwrap()).unwrap();
let _i = nets.iter().position(|&element| element == _tmp).unwrap();
Where nets is a &Vec<f32>. Which to me seems blatantly incorrect.
The Python equivalent of this that works (taking into consideration the above assumption):
_i = nets.index(max(nets))